Skip to content

Commit

Permalink
rewrite emit-shared-files to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 5, 2024
1 parent 11dd90f commit f77d5d2
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 47 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ run-make/dep-info/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
run-make/emit-path-unhashed/Makefile
run-make/emit-shared-files/Makefile
run-make/emit-to-stdout/Makefile
run-make/env-dep-info/Makefile
run-make/export-executable-symbols/Makefile
Expand Down
46 changes: 0 additions & 46 deletions tests/run-make/emit-shared-files/Makefile

This file was deleted.

102 changes: 102 additions & 0 deletions tests/run-make/emit-shared-files/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// This test checks the functionality of one of rustdoc's unstable options,
// the ability to specify emit restrictions with `--emit`.
// `invocation-only` should only emit crate-specific files.
// `toolchain-only` should only emit toolchain-specific files.
// `all-shared` should only emit files that can be shared between crates.
// See https://github.com/rust-lang/rust/pull/83478

use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files};
use std::path::Path;

fn main() {
rustdoc()
.arg("-Zunstable-options")
.arg("--emit=invocation-specific")
.output("invocation-only")
.arg("--resource-suffix=-xxx")
.args(&["--theme", "y.css"])
.args(&["--extend-css", "z.css"])
.input("x.rs")
.run();
assert!(Path::new("invocation-only/search-index-xxx.js").exists());
assert!(Path::new("invocation-only/settings.html").exists());
assert!(Path::new("invocation-only/x/all.html").exists());
assert!(Path::new("invocation-only/x/index.html").exists());
assert!(Path::new("invocation-only/theme-xxx.css").exists()); // generated from z.css
assert!(!Path::new("invocation-only/storage-xxx.js").exists());
assert!(!Path::new("invocation-only/SourceSerif4-It.ttf.woff2").exists());
// FIXME: this probably shouldn't have a suffix
assert!(Path::new("invocation-only/y-xxx.css").exists());
// FIXME: this is technically incorrect (see `write_shared`)
assert!(!Path::new("invocation-only/main-xxx.js").exists());

rustdoc()
.arg("-Zunstable-options")
.arg("--emit=toolchain-shared-resources")
.output("toolchain-only")
.arg("--resource-suffix=-xxx")
.args(&["--extend-css", "z.css"])
.input("x.rs")
.run();
assert_eq!(
shallow_find_files("toolchain-only/static.files", |path| {
has_prefix(path, "storage-") && has_extension(path, "js")
})
.len(),
1
);
assert_eq!(
shallow_find_files("toolchain-only/static.files", |path| {
has_prefix(path, "SourceSerif4-It-") && has_extension(path, "woff2")
})
.len(),
1
);
assert_eq!(
shallow_find_files("toolchain-only/static.files", |path| {
has_prefix(path, "main-") && has_extension(path, "js")
})
.len(),
1
);
assert!(!Path::new("toolchain-only/search-index-xxx.js").exists());
assert!(!Path::new("toolchain-only/x/index.html").exists());
assert!(!Path::new("toolchain-only/theme.css").exists());
assert!(!Path::new("toolchain-only/y-xxx.css").exists());

rustdoc()
.arg("-Zunstable-options")
.arg("--emit=toolchain-shared-resources,unversioned-shared-resources")
.output("all-shared")
.arg("--resource-suffix=-xxx")
.args(&["--extend-css", "z.css"])
.input("x.rs")
.run();
assert_eq!(
shallow_find_files("all-shared/static.files", |path| {
has_prefix(path, "storage-") && has_extension(path, "js")
})
.len(),
1
);
assert_eq!(
shallow_find_files("all-shared/static.files", |path| {
has_prefix(path, "SourceSerif4-It-") && has_extension(path, "woff2")
})
.len(),
1
);
assert!(!Path::new("all-shared/search-index-xxx.js").exists());
assert!(!Path::new("all-shared/settings.html").exists());
assert!(!Path::new("all-shared/x").exists());
assert!(!Path::new("all-shared/src").exists());
assert!(!Path::new("all-shared/theme.css").exists());
assert_eq!(
shallow_find_files("all-shared/static.files", |path| {
has_prefix(path, "main-") && has_extension(path, "js")
})
.len(),
1
);
assert!(!Path::new("all-shared/y-xxx.css").exists());
}

0 comments on commit f77d5d2

Please sign in to comment.