diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index b7fad9719..aa7c887d6 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | use std::fs; | 1 | use std::fs; |
2 | 2 | ||
3 | use test_utils::{assert_eq_text, project_dir, read_text}; | 3 | use expect::{expect_file, ExpectFile}; |
4 | use test_utils::project_dir; | ||
4 | 5 | ||
5 | use crate::{mock_analysis::single_file, FileRange, TextRange}; | 6 | use crate::{mock_analysis::single_file, FileRange, TextRange}; |
6 | 7 | ||
@@ -91,7 +92,7 @@ impl<T> Option<T> { | |||
91 | } | 92 | } |
92 | "# | 93 | "# |
93 | .trim(), | 94 | .trim(), |
94 | "crates/ra_ide/src/snapshots/highlighting.html", | 95 | expect_file!["crates/ra_ide/test_data/highlighting.html"], |
95 | false, | 96 | false, |
96 | ); | 97 | ); |
97 | } | 98 | } |
@@ -114,7 +115,7 @@ fn bar() { | |||
114 | } | 115 | } |
115 | "# | 116 | "# |
116 | .trim(), | 117 | .trim(), |
117 | "crates/ra_ide/src/snapshots/rainbow_highlighting.html", | 118 | expect_file!["crates/ra_ide/test_data/rainbow_highlighting.html"], |
118 | true, | 119 | true, |
119 | ); | 120 | ); |
120 | } | 121 | } |
@@ -167,7 +168,7 @@ fn main() { | |||
167 | ); | 168 | ); |
168 | }"## | 169 | }"## |
169 | .trim(), | 170 | .trim(), |
170 | "crates/ra_ide/src/snapshots/highlight_injection.html", | 171 | expect_file!["crates/ra_ide/test_data/highlight_injection.html"], |
171 | false, | 172 | false, |
172 | ); | 173 | ); |
173 | } | 174 | } |
@@ -250,7 +251,7 @@ fn main() { | |||
250 | println!("{ничоси}", ничоси = 92); | 251 | println!("{ничоси}", ничоси = 92); |
251 | }"# | 252 | }"# |
252 | .trim(), | 253 | .trim(), |
253 | "crates/ra_ide/src/snapshots/highlight_strings.html", | 254 | expect_file!["crates/ra_ide/test_data/highlight_strings.html"], |
254 | false, | 255 | false, |
255 | ); | 256 | ); |
256 | } | 257 | } |
@@ -278,7 +279,7 @@ fn main() { | |||
278 | } | 279 | } |
279 | "# | 280 | "# |
280 | .trim(), | 281 | .trim(), |
281 | "crates/ra_ide/src/snapshots/highlight_unsafe.html", | 282 | expect_file!["crates/ra_ide/test_data/highlight_unsafe.html"], |
282 | false, | 283 | false, |
283 | ); | 284 | ); |
284 | } | 285 | } |
@@ -354,7 +355,7 @@ macro_rules! noop { | |||
354 | } | 355 | } |
355 | "# | 356 | "# |
356 | .trim(), | 357 | .trim(), |
357 | "crates/ra_ide/src/snapshots/highlight_doctest.html", | 358 | expect_file!["crates/ra_ide/test_data/highlight_doctest.html"], |
358 | false, | 359 | false, |
359 | ); | 360 | ); |
360 | } | 361 | } |
@@ -362,11 +363,8 @@ macro_rules! noop { | |||
362 | /// Highlights the code given by the `ra_fixture` argument, renders the | 363 | /// Highlights the code given by the `ra_fixture` argument, renders the |
363 | /// result as HTML, and compares it with the HTML file given as `snapshot`. | 364 | /// result as HTML, and compares it with the HTML file given as `snapshot`. |
364 | /// Note that the `snapshot` file is overwritten by the rendered HTML. | 365 | /// Note that the `snapshot` file is overwritten by the rendered HTML. |
365 | fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { | 366 | fn check_highlighting(ra_fixture: &str, expect: ExpectFile, rainbow: bool) { |
366 | let (analysis, file_id) = single_file(ra_fixture); | 367 | let (analysis, file_id) = single_file(ra_fixture); |
367 | let dst_file = project_dir().join(snapshot); | ||
368 | let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); | 368 | let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); |
369 | let expected_html = &read_text(&dst_file); | 369 | expect.assert_eq(actual_html) |
370 | fs::write(dst_file, &actual_html).unwrap(); | ||
371 | assert_eq_text!(expected_html, actual_html); | ||
372 | } | 370 | } |