Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1bc1993
make cargo test work for bootstrap self test
Shourya742 Sep 15, 2025
a12969e
walk up the ancestors
Shourya742 Sep 15, 2025
6c79f54
add an API in ConfigBuilder to point to config file for toml parsing
Shourya742 Sep 16, 2025
d488d33
let verify method run in test settings
Shourya742 Sep 16, 2025
ce4604e
remove using default toml config for test in get_toml, we handle it v…
Shourya742 Sep 16, 2025
24ed1a0
allow symlinking during test
Shourya742 Sep 16, 2025
05131bd
move most of the test to new testCtx
Shourya742 Sep 16, 2025
a29474d
this is dicy, whether we have a method to explicitly enable_llvm_over…
Shourya742 Sep 16, 2025
0c68c82
rename config_toml to with_default_toml_config
Shourya742 Sep 21, 2025
9189bf7
remove create_config_without_ci_llvm_override duplication
Shourya742 Sep 21, 2025
671aabd
add dry_run flag in config builder and remove runtime test hacks
Shourya742 Sep 21, 2025
afe380d
initialize out with CARGO_TARGET_DIR and then go for manifest and the…
Shourya742 Sep 21, 2025
a48cd76
add explicit config assignment when running the test, as the src is a…
Shourya742 Sep 21, 2025
33e262e
remove prepare_test_specific_dir and update tests accordingly
Shourya742 Sep 21, 2025
6adbb3a
remove explicit target assignment in config during rustc initialization
Shourya742 Sep 22, 2025
8a0e380
add check for toml file
Shourya742 Sep 22, 2025
83b784f
add comment explaining the test_build_dir
Shourya742 Sep 22, 2025
aaa82ae
move config check logic from get_toml to parse_inner
Shourya742 Sep 22, 2025
079addf
Ensure that `--build-dir` is always specified in tests
Kobzol Sep 25, 2025
191c7ed
Make `cargo test` work again
Kobzol Sep 25, 2025
File filter

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
Make cargo test work again
  • Loading branch information
Kobzol committed Sep 25, 2025
commit 191c7ed10f68c6891ba66e342fa58342e16db402
38 changes: 30 additions & 8 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,17 @@ impl Config {
// Set config values based on flags.
let mut exec_ctx = ExecutionContext::new(flags_verbose, flags_cmd.fail_fast());
exec_ctx.set_dry_run(if flags_dry_run { DryRun::UserSelected } else { DryRun::Disabled });
let mut src = {

let default_src_dir = {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// Undo `src/bootstrap`
manifest_dir.parent().unwrap().parent().unwrap().to_owned()
};

if let Some(src_) = compute_src_directory(flags_src, &exec_ctx) {
src = src_;
}
let src = if let Some(s) = compute_src_directory(flags_src, &exec_ctx) {
s
} else {
default_src_dir.clone()
};

#[cfg(test)]
{
Expand Down Expand Up @@ -659,6 +661,10 @@ impl Config {
out
};

let default_stage0_rustc_path = |dir: &Path| {
dir.join(host_target).join("stage0").join("bin").join(exe("rustc", host_target))
};

if cfg!(test) {
// When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
// same ones used to call the tests (if custom ones are not defined in the toml). If we
Expand All @@ -667,6 +673,22 @@ impl Config {
// Cargo in their bootstrap.toml.
build_rustc = build_rustc.take().or(std::env::var_os("RUSTC").map(|p| p.into()));
build_cargo = build_cargo.take().or(std::env::var_os("CARGO").map(|p| p.into()));

// If we are running only `cargo test` (and not `x test bootstrap`), which is useful
// e.g. for debugging bootstrap itself, then we won't have RUSTC and CARGO set to the
// proper paths.
// We thus "guess" that the build directory is located at <src>/build, and try to load
// rustc and cargo from there
let is_test_outside_x = std::env::var("CARGO_TARGET_DIR").is_err();
if is_test_outside_x && build_rustc.is_none() {
let stage0_rustc = default_stage0_rustc_path(&default_src_dir.join("build"));
assert!(
stage0_rustc.exists(),
"Trying to run cargo test without having a stage0 rustc available in {}",
stage0_rustc.display()
);
build_rustc = Some(stage0_rustc);
}
}

if !flags_skip_stage0_validation {
Expand Down Expand Up @@ -700,7 +722,7 @@ impl Config {

let initial_rustc = build_rustc.unwrap_or_else(|| {
download_beta_toolchain(&dwn_ctx, &out);
out.join(host_target).join("stage0").join("bin").join(exe("rustc", host_target))
default_stage0_rustc_path(&out)
});

let initial_sysroot = t!(PathBuf::from_str(
Expand Down Expand Up @@ -1540,11 +1562,11 @@ impl Config {
println!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled.");
println!("HELP: Consider rebasing to a newer commit if available.");
return None;
},
}
Err(e) => {
eprintln!("ERROR: Failed to parse CI rustc bootstrap.toml: {e}");
exit!(2);
},
}
};

let current_config_toml = Self::get_toml(config_path).unwrap();
Expand Down
Loading