Migrate `run-make/rustdoc-themes` to new rmake · rust-lang/rust@c765480

File tree

3 files changed

lines changed

  • tests/run-make/rustdoc-themes

3 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -246,7 +246,6 @@ run-make/rustdoc-scrape-examples-multiple/Makefile

246246

run-make/rustdoc-scrape-examples-remap/Makefile

247247

run-make/rustdoc-scrape-examples-test/Makefile

248248

run-make/rustdoc-scrape-examples-whitespace/Makefile

249-

run-make/rustdoc-themes/Makefile

250249

run-make/rustdoc-verify-output-files/Makefile

251250

run-make/rustdoc-with-out-dir-option/Makefile

252251

run-make/rustdoc-with-output-option/Makefile

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,31 @@

1+

// Test that rustdoc will properly load in a theme file and display it in the theme selector.

2+
3+

use run_make_support::{htmldocck, rustdoc, source_path, tmp_dir};

4+
5+

fn main() {

6+

let out_dir = tmp_dir().join("rustdoc-themes");

7+

let test_css = out_dir.join("test.css");

8+
9+

let no_script =

10+

std::fs::read_to_string(source_path().join("src/librustdoc/html/static/css/noscript.css"))

11+

.unwrap();

12+
13+

let mut test_content = String::new();

14+

let mut found_begin_light = false;

15+

for line in no_script.split('\n') {

16+

if line == "/* Begin theme: light */" {

17+

found_begin_light = true;

18+

} else if line == "/* End theme: light */" {

19+

break;

20+

} else if found_begin_light {

21+

test_content.push_str(line);

22+

test_content.push('\n');

23+

}

24+

}

25+

assert!(!test_content.is_empty());

26+

std::fs::create_dir_all(&out_dir).unwrap();

27+

std::fs::write(&test_css, test_content).unwrap();

28+
29+

rustdoc().output(&out_dir).input("foo.rs").arg("--theme").arg(&test_css).run();

30+

htmldocck().arg(out_dir).arg("foo.rs").status().unwrap().success();

31+

}