Skip to content

Commit 4f22342

Browse files
Migrate run-make/rustdoc-verify-output-files to rmake.rs
1 parent 3b0ad79 commit 4f22342

File tree

3 files changed

+43
-33
lines changed

3 files changed

+43
-33
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 1 deletion
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

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

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
fn generate_docs(out_dir: &Path, json_output: bool) {
7+
let mut rustdoc = rustdoc();
8+
rustdoc.input("src/lib.rs").crate_name("foobar").crate_type("lib").out_dir(&out_dir);
9+
if json_output {
10+
rustdoc.arg("-Zunstable-options").output_format("json");
11+
}
12+
rustdoc.run();
13+
}
14+
15+
fn main() {
16+
let out_dir = tmp_dir().join("rustdoc");
17+
let tmp_out_dir = tmp_dir().join("tmp-rustdoc");
18+
19+
// Generate HTML docs.
20+
generate_docs(&out_dir, false);
21+
22+
// Copy first output for to check if it's exactly same after second compilation.
23+
copy_dir_all(&out_dir, &tmp_out_dir);
24+
25+
// Generate html docs once again on same output.
26+
generate_docs(&out_dir, false);
27+
28+
// Generate json doc on the same output.
29+
generate_docs(&out_dir, true);
30+
31+
// Check if expected json file is generated.
32+
assert!(out_dir.join("foobar.json").is_file());
33+
34+
// Copy first json output to check if it's exactly same after second compilation.
35+
copy(out_dir.join("foobar.json"), tmp_out_dir.join("foobar.json")).unwrap();
36+
37+
// Generate json doc on the same output.
38+
generate_docs(&out_dir, true);
39+
40+
// Check if all docs(including both json and html formats) are still the same after multiple
41+
// compilations.
42+
recursive_diff(&out_dir, &tmp_out_dir);
43+
}

0 commit comments

Comments
 (0)