aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-23 17:56:26 +0100
committerAleksey Kladov <[email protected]>2020-06-23 17:56:26 +0100
commit84cd28fddc89bfa75760e81f4fbc5aa21ce2742c (patch)
treee3a4ea586b680132224e542e53e312c24ce958b1 /crates/test_utils
parentfdf86aee18e396d393d50df7df27b02111838507 (diff)
Cut problematic dependency
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/Cargo.toml3
-rw-r--r--crates/test_utils/src/fixture.rs28
-rw-r--r--crates/test_utils/src/lib.rs1
3 files changed, 20 insertions, 12 deletions
diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml
index afd2005f8..6821db1e8 100644
--- a/crates/test_utils/Cargo.toml
+++ b/crates/test_utils/Cargo.toml
@@ -8,10 +8,9 @@ authors = ["rust-analyzer developers"]
8doctest = false 8doctest = false
9 9
10[dependencies] 10[dependencies]
11# Avoid adding deps here, this crate is widely used in tests it should compile fast!
11difference = "2.0.0" 12difference = "2.0.0"
12text-size = "1.0.0" 13text-size = "1.0.0"
13serde_json = "1.0.48" 14serde_json = "1.0.48"
14rustc-hash = "1.1.0" 15rustc-hash = "1.1.0"
15
16ra_cfg = { path = "../ra_cfg" }
17stdx = { path = "../stdx" } 16stdx = { path = "../stdx" }
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index 2a51bb559..44cf835b3 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -1,4 +1,3 @@
1use ra_cfg::CfgOptions;
2use rustc_hash::FxHashMap; 1use rustc_hash::FxHashMap;
3use stdx::split1; 2use stdx::split1;
4 3
@@ -8,7 +7,8 @@ pub struct Fixture {
8 pub text: String, 7 pub text: String,
9 pub crate_name: Option<String>, 8 pub crate_name: Option<String>,
10 pub deps: Vec<String>, 9 pub deps: Vec<String>,
11 pub cfg: CfgOptions, 10 pub cfg_atoms: Vec<String>,
11 pub cfg_key_values: Vec<(String, String)>,
12 pub edition: Option<String>, 12 pub edition: Option<String>,
13 pub env: FxHashMap<String, String>, 13 pub env: FxHashMap<String, String>,
14} 14}
@@ -73,7 +73,8 @@ The offending line: {:?}"#,
73 let mut krate = None; 73 let mut krate = None;
74 let mut deps = Vec::new(); 74 let mut deps = Vec::new();
75 let mut edition = None; 75 let mut edition = None;
76 let mut cfg = CfgOptions::default(); 76 let mut cfg_atoms = Vec::new();
77 let mut cfg_key_values = Vec::new();
77 let mut env = FxHashMap::default(); 78 let mut env = FxHashMap::default();
78 for component in components[1..].iter() { 79 for component in components[1..].iter() {
79 let (key, value) = split1(component, ':').unwrap(); 80 let (key, value) = split1(component, ':').unwrap();
@@ -82,10 +83,10 @@ The offending line: {:?}"#,
82 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(), 83 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
83 "edition" => edition = Some(value.to_string()), 84 "edition" => edition = Some(value.to_string()),
84 "cfg" => { 85 "cfg" => {
85 for key in value.split(',') { 86 for entry in value.split(',') {
86 match split1(key, '=') { 87 match split1(entry, '=') {
87 None => cfg.insert_atom(key.into()), 88 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
88 Some((k, v)) => cfg.insert_key_value(k.into(), v.into()), 89 None => cfg_atoms.push(entry.to_string()),
89 } 90 }
90 } 91 }
91 } 92 }
@@ -100,7 +101,16 @@ The offending line: {:?}"#,
100 } 101 }
101 } 102 }
102 103
103 Fixture { path, text: String::new(), crate_name: krate, deps, edition, cfg, env } 104 Fixture {
105 path,
106 text: String::new(),
107 crate_name: krate,
108 deps,
109 cfg_atoms,
110 cfg_key_values,
111 edition,
112 env,
113 }
104 } 114 }
105} 115}
106 116
@@ -152,7 +162,7 @@ fn indent_len(s: &str) -> usize {
152#[test] 162#[test]
153#[should_panic] 163#[should_panic]
154fn parse_fixture_checks_further_indented_metadata() { 164fn parse_fixture_checks_further_indented_metadata() {
155 parse_fixture( 165 Fixture::parse(
156 r" 166 r"
157 //- /lib.rs 167 //- /lib.rs
158 mod bar; 168 mod bar;
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 316f3d501..3fd8505ed 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -19,7 +19,6 @@ use serde_json::Value;
19use text_size::{TextRange, TextSize}; 19use text_size::{TextRange, TextSize};
20 20
21pub use difference::Changeset as __Changeset; 21pub use difference::Changeset as __Changeset;
22pub use ra_cfg::CfgOptions;
23pub use rustc_hash::FxHashMap; 22pub use rustc_hash::FxHashMap;
24 23
25pub use crate::fixture::Fixture; 24pub use crate::fixture::Fixture;