Skip to content

Commit 3c489a3

Browse files
Update highlight tests
1 parent ad4ccf9 commit 3c489a3

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/librustdoc/html/highlight/tests.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use super::write_code;
22
use crate::html::format::Buffer;
33
use expect_test::expect_file;
44
use rustc_span::edition::Edition;
5+
use rustc_span::with_default_session_globals;
56

67
const STYLE: &str = r#"
78
<style>
@@ -17,21 +18,25 @@ const STYLE: &str = r#"
1718

1819
#[test]
1920
fn test_html_highlighting() {
20-
let src = include_str!("fixtures/sample.rs");
21-
let html = {
22-
let mut out = Buffer::new();
23-
write_code(&mut out, src, Edition::Edition2018);
24-
format!("{}<pre><code>{}</code></pre>\n", STYLE, out.into_inner())
25-
};
26-
expect_file!["fixtures/sample.html"].assert_eq(&html);
21+
with_default_session_globals(|| {
22+
let src = include_str!("fixtures/sample.rs");
23+
let html = {
24+
let mut out = Buffer::new();
25+
write_code(&mut out, src, Edition::Edition2018);
26+
format!("{}<pre><code>{}</code></pre>\n", STYLE, out.into_inner())
27+
};
28+
expect_file!["fixtures/sample.html"].assert_eq(&html);
29+
});
2730
}
2831

2932
#[test]
3033
fn test_dos_backline() {
31-
let src = "pub fn foo() {\r\n\
34+
with_default_session_globals(|| {
35+
let src = "pub fn foo() {\r\n\
3236
println!(\"foo\");\r\n\
3337
}\r\n";
34-
let mut html = Buffer::new();
35-
write_code(&mut html, src, Edition::Edition2018);
36-
expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner());
38+
let mut html = Buffer::new();
39+
write_code(&mut html, src, Edition::Edition2018);
40+
expect_file!["fixtures/dos_line.html"].assert_eq(&html.into_inner());
41+
});
3742
}

0 commit comments

Comments
 (0)