Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bdf3864

Browse files
committedMay 27, 2024
Migrate run-make/rustdoc-verify-output-files to rmake.rs
1 parent f0ab814 commit bdf3864

File tree

3 files changed

+49
-33
lines changed

3 files changed

+49
-33
lines changed
 

Diff for: ‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ run-make/rlib-format-packed-bundled-libs/Makefile
227227
run-make/rmeta-preferred/Makefile
228228
run-make/rustc-macro-dep-files/Makefile
229229
run-make/rustdoc-io-error/Makefile
230-
run-make/rustdoc-verify-output-files/Makefile
231230
run-make/sanitizer-cdylib-link/Makefile
232231
run-make/sanitizer-dylib-link/Makefile
233232
run-make/sanitizer-staticlib-link/Makefile

Diff for: ‎tests/run-make/rustdoc-verify-output-files/Makefile

-32
This file was deleted.

Diff for: ‎tests/run-make/rustdoc-verify-output-files/rmake.rs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use std::fs::copy;
2+
use std::path::{Path, PathBuf};
3+
4+
use run_make_support::{copy_dir_all, recursive_diff, rustdoc, tmp_dir};
5+
6+
#[derive(PartialEq)]
7+
enum JsonOutput {
8+
Yes,
9+
No,
10+
}
11+
12+
fn generate_docs(out_dir: &Path, json_output: JsonOutput) {
13+
let mut rustdoc = rustdoc();
14+
rustdoc.input("src/lib.rs").crate_name("foobar").crate_type("lib").out_dir(&out_dir);
15+
if json_output == JsonOutput::Yes {
16+
rustdoc.arg("-Zunstable-options").output_format("json");
17+
}
18+
rustdoc.run();
19+
}
20+
21+
fn main() {
22+
let out_dir = tmp_dir().join("rustdoc");
23+
let tmp_out_dir = tmp_dir().join("tmp-rustdoc");
24+
25+
// Generate HTML docs.
26+
generate_docs(&out_dir, JsonOutput::No);
27+
28+
// Copy first output for to check if it's exactly same after second compilation.
29+
copy_dir_all(&out_dir, &tmp_out_dir);
30+
31+
// Generate html docs once again on same output.
32+
generate_docs(&out_dir, JsonOutput::No);
33+
34+
// Generate json doc on the same output.
35+
generate_docs(&out_dir, JsonOutput::Yes);
36+
37+
// Check if expected json file is generated.
38+
assert!(out_dir.join("foobar.json").is_file());
39+
40+
// Copy first json output to check if it's exactly same after second compilation.
41+
copy(out_dir.join("foobar.json"), tmp_out_dir.join("foobar.json")).unwrap();
42+
43+
// Generate json doc on the same output.
44+
generate_docs(&out_dir, JsonOutput::Yes);
45+
46+
// Check if all docs(including both json and html formats) are still the same after multiple
47+
// compilations.
48+
recursive_diff(&out_dir, &tmp_out_dir);
49+
}

0 commit comments

Comments
 (0)
Failed to load comments.