Skip to content
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
44 changes: 34 additions & 10 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3337,33 +3337,57 @@ fn distcheck_rustc_dev(builder: &Builder<'_>, dir: &Path) {
builder.remove_dir(dir);
}

/// Runs unit tests in `bootstrap_test.py`, which test the Python parts of bootstrap.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Bootstrap;
pub(crate) struct BootstrapPy;

impl Step for Bootstrap {
impl Step for BootstrapPy {
type Output = ();
const DEFAULT: bool = true;
const IS_HOST: bool = true;

/// Tests the build system itself.
fn run(self, builder: &Builder<'_>) {
let host = builder.config.host_target;
let build_compiler = builder.compiler(0, host);
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
// Bootstrap tests might not be perfectly self-contained and can depend
Copy link
Member

Choose a reason for hiding this comment

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

I think the bootstrap Python tests should be fine locally, but they are IMO not very useful anyway, so let's just run them only on CI.

// on the environment, so only run them by default in CI, not locally.
// See `test::Bootstrap::should_run`.
let is_ci = run.builder.config.is_running_on_ci;
run.alias("bootstrap-py").default_condition(is_ci)
}

// Some tests require cargo submodule to be present.
builder.build.require_submodule("src/tools/cargo", None);
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(BootstrapPy)
}

fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut check_bootstrap = command(builder.python());
check_bootstrap
.args(["-m", "unittest", "bootstrap_test.py"])
// Forward command-line args after `--` to unittest, for filtering etc.
.args(builder.config.test_args())
.env("BUILD_DIR", &builder.out)
.env("BUILD_PLATFORM", builder.build.host_target.triple)
.env("BOOTSTRAP_TEST_RUSTC_BIN", &builder.initial_rustc)
.env("BOOTSTRAP_TEST_CARGO_BIN", &builder.initial_cargo)
.current_dir(builder.src.join("src/bootstrap/"));
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
// Use `python -m unittest` manually if you want to pass arguments.
check_bootstrap.delay_failure().run(builder);
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Bootstrap;

impl Step for Bootstrap {
type Output = ();
const DEFAULT: bool = true;
const IS_HOST: bool = true;

/// Tests the build system itself.
fn run(self, builder: &Builder<'_>) {
let host = builder.config.host_target;
let build_compiler = builder.compiler(0, host);

// Some tests require cargo submodule to be present.
builder.build.require_submodule("src/tools/cargo", None);

let mut cargo = tool::prepare_tool_cargo(
builder,
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ impl<'a> Builder<'a> {
Kind::Test => describe!(
crate::core::build_steps::toolstate::ToolStateCheck,
test::Tidy,
test::BootstrapPy,
test::Bootstrap,
test::Ui,
test::Crashes,
Expand Down
Loading