diff options
-rw-r--r-- | crates/ra_db/src/fixture.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/mock_analysis.rs | 7 | ||||
-rw-r--r-- | crates/rust-analyzer/tests/heavy_tests/support.rs | 2 | ||||
-rw-r--r-- | crates/test_utils/src/lib.rs | 8 |
4 files changed, 10 insertions, 11 deletions
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs index 6e2c7ff72..8b62fe9aa 100644 --- a/crates/ra_db/src/fixture.rs +++ b/crates/ra_db/src/fixture.rs | |||
@@ -99,7 +99,7 @@ fn with_single_file(db: &mut dyn SourceDatabaseExt, ra_fixture: &str) -> FileId | |||
99 | let fixture = parse_single_fixture(ra_fixture); | 99 | let fixture = parse_single_fixture(ra_fixture); |
100 | 100 | ||
101 | let crate_graph = if let Some(entry) = fixture { | 101 | let crate_graph = if let Some(entry) = fixture { |
102 | let meta = match ParsedMeta::from(&entry.parsed_meta) { | 102 | let meta = match ParsedMeta::from(&entry.meta) { |
103 | ParsedMeta::File(it) => it, | 103 | ParsedMeta::File(it) => it, |
104 | _ => panic!("with_single_file only support file meta"), | 104 | _ => panic!("with_single_file only support file meta"), |
105 | }; | 105 | }; |
@@ -156,7 +156,7 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option<FilePosit | |||
156 | let mut file_position = None; | 156 | let mut file_position = None; |
157 | 157 | ||
158 | for entry in fixture.iter() { | 158 | for entry in fixture.iter() { |
159 | let meta = match ParsedMeta::from(&entry.parsed_meta) { | 159 | let meta = match ParsedMeta::from(&entry.meta) { |
160 | ParsedMeta::Root { path } => { | 160 | ParsedMeta::Root { path } => { |
161 | let source_root = std::mem::replace(&mut source_root, SourceRoot::new_local()); | 161 | let source_root = std::mem::replace(&mut source_root, SourceRoot::new_local()); |
162 | db.set_source_root(source_root_id, Arc::new(source_root)); | 162 | db.set_source_root(source_root_id, Arc::new(source_root)); |
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index 2c13f206a..64c0684c5 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs | |||
@@ -35,7 +35,7 @@ impl MockAnalysis { | |||
35 | pub fn with_files(fixture: &str) -> MockAnalysis { | 35 | pub fn with_files(fixture: &str) -> MockAnalysis { |
36 | let mut res = MockAnalysis::new(); | 36 | let mut res = MockAnalysis::new(); |
37 | for entry in parse_fixture(fixture) { | 37 | for entry in parse_fixture(fixture) { |
38 | res.add_file(&entry.meta, &entry.text); | 38 | res.add_file(entry.meta.path().as_str(), &entry.text); |
39 | } | 39 | } |
40 | res | 40 | res |
41 | } | 41 | } |
@@ -48,9 +48,10 @@ impl MockAnalysis { | |||
48 | for entry in parse_fixture(fixture) { | 48 | for entry in parse_fixture(fixture) { |
49 | if entry.text.contains(CURSOR_MARKER) { | 49 | if entry.text.contains(CURSOR_MARKER) { |
50 | assert!(position.is_none(), "only one marker (<|>) per fixture is allowed"); | 50 | assert!(position.is_none(), "only one marker (<|>) per fixture is allowed"); |
51 | position = Some(res.add_file_with_position(&entry.meta, &entry.text)); | 51 | position = |
52 | Some(res.add_file_with_position(&entry.meta.path().as_str(), &entry.text)); | ||
52 | } else { | 53 | } else { |
53 | res.add_file(&entry.meta, &entry.text); | 54 | res.add_file(&entry.meta.path().as_str(), &entry.text); |
54 | } | 55 | } |
55 | } | 56 | } |
56 | let position = position.expect("expected a marker (<|>)"); | 57 | let position = position.expect("expected a marker (<|>)"); |
diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs index 8756ad4a3..7679e9ad7 100644 --- a/crates/rust-analyzer/tests/heavy_tests/support.rs +++ b/crates/rust-analyzer/tests/heavy_tests/support.rs | |||
@@ -68,7 +68,7 @@ impl<'a> Project<'a> { | |||
68 | let mut paths = vec![]; | 68 | let mut paths = vec![]; |
69 | 69 | ||
70 | for entry in parse_fixture(self.fixture) { | 70 | for entry in parse_fixture(self.fixture) { |
71 | let path = tmp_dir.path().join(entry.meta); | 71 | let path = tmp_dir.path().join(entry.meta.path().as_str()); |
72 | fs::create_dir_all(path.parent().unwrap()).unwrap(); | 72 | fs::create_dir_all(path.parent().unwrap()).unwrap(); |
73 | fs::write(path.as_path(), entry.text.as_bytes()).unwrap(); | 73 | fs::write(path.as_path(), entry.text.as_bytes()).unwrap(); |
74 | paths.push((path, entry.text)); | 74 | paths.push((path, entry.text)); |
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 0c367ce71..6a8d06ea7 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -161,10 +161,8 @@ pub fn add_cursor(text: &str, offset: TextSize) -> String { | |||
161 | 161 | ||
162 | #[derive(Debug, Eq, PartialEq)] | 162 | #[derive(Debug, Eq, PartialEq)] |
163 | pub struct FixtureEntry { | 163 | pub struct FixtureEntry { |
164 | pub meta: String, | 164 | pub meta: FixtureMeta, |
165 | pub text: String, | 165 | pub text: String, |
166 | |||
167 | pub parsed_meta: FixtureMeta, | ||
168 | } | 166 | } |
169 | 167 | ||
170 | #[derive(Debug, Eq, PartialEq)] | 168 | #[derive(Debug, Eq, PartialEq)] |
@@ -231,8 +229,8 @@ The offending line: {:?}"#, | |||
231 | for line in lines.by_ref() { | 229 | for line in lines.by_ref() { |
232 | if line.starts_with("//-") { | 230 | if line.starts_with("//-") { |
233 | let meta = line["//-".len()..].trim().to_string(); | 231 | let meta = line["//-".len()..].trim().to_string(); |
234 | let parsed_meta = parse_meta(&meta); | 232 | let meta = parse_meta(&meta); |
235 | res.push(FixtureEntry { meta, parsed_meta, text: String::new() }) | 233 | res.push(FixtureEntry { meta, text: String::new() }) |
236 | } else if let Some(entry) = res.last_mut() { | 234 | } else if let Some(entry) = res.last_mut() { |
237 | entry.text.push_str(line); | 235 | entry.text.push_str(line); |
238 | entry.text.push('\n'); | 236 | entry.text.push('\n'); |