From 2f4861c0e647567b80832ade1890839db1dc306b Mon Sep 17 00:00:00 2001 From: Jover Zhang Date: Sat, 4 May 2024 15:52:42 +0800 Subject: [PATCH] Rewrite `rustdoc-determinism` test in Rust --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/rustdoc-determinism/Makefile | 16 ---------------- tests/run-make/rustdoc-determinism/rmake.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 tests/run-make/rustdoc-determinism/Makefile create mode 100644 tests/run-make/rustdoc-determinism/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 4b79b910ec3..4abaf65726d 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -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 diff --git a/tests/run-make/rustdoc-determinism/Makefile b/tests/run-make/rustdoc-determinism/Makefile deleted file mode 100644 index a3ef1690671..00000000000 --- a/tests/run-make/rustdoc-determinism/Makefile +++ /dev/null @@ -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 diff --git a/tests/run-make/rustdoc-determinism/rmake.rs b/tests/run-make/rustdoc-determinism/rmake.rs new file mode 100644 index 00000000000..38ae75199fd --- /dev/null +++ b/tests/run-make/rustdoc-determinism/rmake.rs @@ -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(); +}