Rewrite rustdoc-determinism test in Rust

This commit is contained in:
Jover Zhang 2024-05-04 15:52:42 +08:00
parent 09cd00fea4
commit 2f4861c0e6
3 changed files with 18 additions and 17 deletions

View File

@ -246,7 +246,6 @@ run-make/rlib-format-packed-bundled-libs-3/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/rmeta-preferred/Makefile
run-make/rustc-macro-dep-files/Makefile
run-make/rustdoc-determinism/Makefile
run-make/rustdoc-error-lines/Makefile
run-make/rustdoc-io-error/Makefile
run-make/rustdoc-map-file/Makefile

View File

@ -1,16 +0,0 @@
include ../tools.mk
# Assert that the search index is generated deterministically, regardless of the
# order that crates are documented in.
# ignore-windows
# Uses `diff`.
all:
$(RUSTDOC) foo.rs -o $(TMPDIR)/foo_first
$(RUSTDOC) bar.rs -o $(TMPDIR)/foo_first
$(RUSTDOC) bar.rs -o $(TMPDIR)/bar_first
$(RUSTDOC) foo.rs -o $(TMPDIR)/bar_first
diff $(TMPDIR)/foo_first/search-index.js $(TMPDIR)/bar_first/search-index.js

View File

@ -0,0 +1,18 @@
use run_make_support::{diff, rustc, rustdoc, tmp_dir};
/// Assert that the search index is generated deterministically, regardless of the
/// order that crates are documented in.
fn main() {
let dir_first = tmp_dir().join("first");
rustdoc().out_dir(&dir_first).input("foo.rs").run();
rustdoc().out_dir(&dir_first).input("bar.rs").run();
let dir_second = tmp_dir().join("second");
rustdoc().out_dir(&dir_second).input("bar.rs").run();
rustdoc().out_dir(&dir_second).input("foo.rs").run();
diff()
.expected_file(dir_first.join("search-index.js"))
.actual_file(dir_second.join("search-index.js"))
.run();
}