From 796835f376fccba1879c13ab40afda64c99551e2 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 30 Dec 2024 23:09:47 +1100 Subject: [PATCH] Make `./x test compiler` actually run the compiler unit tests --- src/bootstrap/src/core/builder/mod.rs | 8 ++++++-- src/bootstrap/src/core/builder/tests.rs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 18beaf3676d5f..b000d8775cfcf 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -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. + // + test::CodegenCranelift, + test::CodegenGCC, test::CrateRustdoc, test::CrateRustdocJsonTypes, test::CrateBootstrap, diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index a0acd83937441..21694cf46fe21 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -786,3 +786,21 @@ mod sysroot_target_dirs { ); } } + +/// Regression test for . +/// +/// 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::(); + let cranelift = cache.contains::(); + let gcc = cache.contains::(); + + assert_eq!((compiler, cranelift, gcc), (true, false, false)); +}