Rollup merge of #124698 - JoverZhang:test-rustdoc-determinism, r=jieyouxu

Rewrite `rustdoc-determinism` test in Rust

Rewrite the `rustdoc-determinism` test from #121876.

r? `@jieyouxu`
This commit is contained in:
Matthias Krüger 2024-05-04 12:37:23 +02:00 committed by GitHub
commit b8711373cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 17 deletions

View File

@ -245,7 +245,6 @@ run-make/rlib-format-packed-bundled-libs-3/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile run-make/rlib-format-packed-bundled-libs/Makefile
run-make/rmeta-preferred/Makefile run-make/rmeta-preferred/Makefile
run-make/rustc-macro-dep-files/Makefile run-make/rustc-macro-dep-files/Makefile
run-make/rustdoc-determinism/Makefile
run-make/rustdoc-error-lines/Makefile run-make/rustdoc-error-lines/Makefile
run-make/rustdoc-io-error/Makefile run-make/rustdoc-io-error/Makefile
run-make/rustdoc-map-file/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();
}