Skip to content

make it possible to use stage0 libtest on compiletest #139386

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

Merged
merged 5 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
implement check step for compiletest separately
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Apr 7, 2025
commit cae28b5119cdb23544a80fafd02f486fdfe1183b
67 changes: 63 additions & 4 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,69 @@ impl Step for RustAnalyzer {
}
}

/// Compiletest is implicitly "checked" when it gets built in order to run tests,
/// so this is mainly for people working on compiletest to run locally.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Compiletest {
pub target: TargetSelection,
}

impl Step for Compiletest {
type Output = ();
const ONLY_HOSTS: bool = true;
const DEFAULT: bool = false;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/compiletest")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Compiletest { target: run.target });
}

fn run(self, builder: &Builder<'_>) {
let mode = if builder.config.compiletest_use_stage0_libtest {
Mode::ToolBootstrap
} else {
Mode::ToolStd
};

let compiler = builder.compiler(
if mode == Mode::ToolBootstrap { 0 } else { builder.top_stage },
builder.config.build,
);

if mode != Mode::ToolBootstrap {
builder.ensure(Rustc::new(self.target, builder));
}

let mut cargo = prepare_tool_cargo(
builder,
compiler,
mode,
self.target,
builder.kind,
"src/tools/compiletest",
SourceType::InTree,
&[],
);

cargo.allow_features("test");

// For ./x.py clippy, don't run with --all-targets because
// linting tests and benchmarks can produce very noisy results
if builder.kind != Kind::Clippy {
cargo.arg("--all-targets");
}

let stamp = BuildStamp::new(&builder.cargo_out(compiler, mode, self.target))
.with_prefix("compiletest-check");

let _guard = builder.msg_check("compiletest artifacts", self.target);
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
}
}

macro_rules! tool_check_step {
(
$name:ident {
Expand Down Expand Up @@ -464,7 +527,3 @@ tool_check_step!(Bootstrap { path: "src/bootstrap", default: false });
// `run-make-support` will be built as part of suitable run-make compiletest test steps, but support
// check to make it easier to work on.
tool_check_step!(RunMakeSupport { path: "src/tools/run-make-support", default: false });

// Compiletest is implicitly "checked" when it gets built in order to run tests,
// so this is mainly for people working on compiletest to run locally.
tool_check_step!(Compiletest { path: "src/tools/compiletest", default: false });
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,9 @@ pub fn run_cargo(
// Ok now we need to actually find all the files listed in `toplevel`. We've
// got a list of prefix/extensions and we basically just need to find the
// most recent file in the `deps` folder corresponding to each one.
let contents = t!(target_deps_dir.read_dir())
let contents = target_deps_dir
.read_dir()
.unwrap_or_else(|e| panic!("Couldn't read {}: {}", target_deps_dir.display(), e))
.map(|e| t!(e))
.map(|e| (e.path(), e.file_name().into_string().unwrap(), t!(e.metadata())))
.collect::<Vec<_>>();
Expand Down
Loading