aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/test_utils/src')
-rw-r--r--crates/test_utils/src/fixture.rs10
-rw-r--r--crates/test_utils/src/lib.rs4
2 files changed, 7 insertions, 7 deletions
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index 099baeca2..d0bddf7d8 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -62,7 +62,7 @@
62//! ``` 62//! ```
63 63
64use rustc_hash::FxHashMap; 64use rustc_hash::FxHashMap;
65use stdx::{lines_with_ends, split_once, trim_indent}; 65use stdx::trim_indent;
66 66
67#[derive(Debug, Eq, PartialEq)] 67#[derive(Debug, Eq, PartialEq)]
68pub struct Fixture { 68pub struct Fixture {
@@ -93,7 +93,7 @@ impl Fixture {
93 93
94 let default = if ra_fixture.contains("//-") { None } else { Some("//- /main.rs") }; 94 let default = if ra_fixture.contains("//-") { None } else { Some("//- /main.rs") };
95 95
96 for (ix, line) in default.into_iter().chain(lines_with_ends(&fixture)).enumerate() { 96 for (ix, line) in default.into_iter().chain(fixture.split_inclusive('\n')).enumerate() {
97 if line.contains("//-") { 97 if line.contains("//-") {
98 assert!( 98 assert!(
99 line.starts_with("//-"), 99 line.starts_with("//-"),
@@ -133,14 +133,14 @@ impl Fixture {
133 let mut env = FxHashMap::default(); 133 let mut env = FxHashMap::default();
134 let mut introduce_new_source_root = false; 134 let mut introduce_new_source_root = false;
135 for component in components[1..].iter() { 135 for component in components[1..].iter() {
136 let (key, value) = split_once(component, ':').unwrap(); 136 let (key, value) = component.split_once(':').unwrap();
137 match key { 137 match key {
138 "crate" => krate = Some(value.to_string()), 138 "crate" => krate = Some(value.to_string()),
139 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(), 139 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
140 "edition" => edition = Some(value.to_string()), 140 "edition" => edition = Some(value.to_string()),
141 "cfg" => { 141 "cfg" => {
142 for entry in value.split(',') { 142 for entry in value.split(',') {
143 match split_once(entry, '=') { 143 match entry.split_once('=') {
144 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())), 144 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
145 None => cfg_atoms.push(entry.to_string()), 145 None => cfg_atoms.push(entry.to_string()),
146 } 146 }
@@ -148,7 +148,7 @@ impl Fixture {
148 } 148 }
149 "env" => { 149 "env" => {
150 for key in value.split(',') { 150 for key in value.split(',') {
151 if let Some((k, v)) = split_once(key, '=') { 151 if let Some((k, v)) = key.split_once('=') {
152 env.insert(k.into(), v.into()); 152 env.insert(k.into(), v.into());
153 } 153 }
154 } 154 }
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 72466c957..fce4fd6bf 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -17,7 +17,7 @@ use std::{
17}; 17};
18 18
19use profile::StopWatch; 19use profile::StopWatch;
20use stdx::{is_ci, lines_with_ends}; 20use stdx::is_ci;
21use text_size::{TextRange, TextSize}; 21use text_size::{TextRange, TextSize};
22 22
23pub use dissimilar::diff as __diff; 23pub use dissimilar::diff as __diff;
@@ -181,7 +181,7 @@ pub fn extract_annotations(text: &str) -> Vec<(TextRange, String)> {
181 let mut prev_line_start: Option<TextSize> = None; 181 let mut prev_line_start: Option<TextSize> = None;
182 let mut line_start: TextSize = 0.into(); 182 let mut line_start: TextSize = 0.into();
183 let mut prev_line_annotations: Vec<(TextSize, usize)> = Vec::new(); 183 let mut prev_line_annotations: Vec<(TextSize, usize)> = Vec::new();
184 for line in lines_with_ends(text) { 184 for line in text.split_inclusive('\n') {
185 let mut this_line_annotations = Vec::new(); 185 let mut this_line_annotations = Vec::new();
186 if let Some(idx) = line.find("//") { 186 if let Some(idx) = line.find("//") {
187 let annotation_offset = TextSize::of(&line[..idx + "//".len()]); 187 let annotation_offset = TextSize::of(&line[..idx + "//".len()]);