Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: Make ./x test compiler actually run the compiler unit tests #134919

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,13 +922,17 @@ impl<'a> Builder<'a> {
test::Incremental,
test::Debuginfo,
test::UiFullDeps,
test::CodegenCranelift,
test::CodegenGCC,
test::Rustdoc,
test::CoverageRunRustdoc,
test::Pretty,
test::Crate,
test::CrateLibrustc,
// The cranelift and gcc tests need to be listed after the
// compiler unit tests (CrateLibrustc) so that they don't
// hijack the whole `compiler` directory during path matching.
// <https://github.com/rust-lang/rust/pull/134919>
test::CodegenCranelift,
test::CodegenGCC,
test::CrateRustdoc,
test::CrateRustdocJsonTypes,
test::CrateBootstrap,
Expand Down
18 changes: 18 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,21 @@ mod sysroot_target_dirs {
);
}
}

/// Regression test for <https://github.com/rust-lang/rust/issues/134916>.
///
/// The command `./x test compiler` should invoke the step that runs unit tests
/// for (most) compiler crates; it should not be hijacked by the cg_clif or
/// cg_gcc tests instead.
#[test]
fn test_test_compiler() {
let cmd = &["test", "compiler"].map(str::to_owned);
let config = configure_with_args(cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
let cache = run_build(&config.paths.clone(), config);

let compiler = cache.contains::<test::CrateLibrustc>();
let cranelift = cache.contains::<test::CodegenCranelift>();
let gcc = cache.contains::<test::CodegenGCC>();

assert_eq!((compiler, cranelift, gcc), (true, false, false));
}
Comment on lines +796 to +806
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have manually verified that this unit test fails before the change, and succeeds after the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried to write a unit test for ./x test rustc_codegen_cranelift and ./x test compiler/rustc_codegen_cranelift, to make sure this PR doesn't break them. But so far I haven't managed to get those tests to work, so for now I've just verified them by hand.

Loading