Auto merge of #134790 - onur-ozkan:cfg-test, r=clubby789
replace bootstrap-self-test feature flag with cfg(test) This makes it in more rusty way.
This commit is contained in:
commit
ceb0441e82
6 changed files with 19 additions and 22 deletions
|
|
@ -7,7 +7,6 @@ default-run = "bootstrap"
|
|||
|
||||
[features]
|
||||
build-metrics = ["sysinfo"]
|
||||
bootstrap-self-test = [] # enabled in the bootstrap unit tests
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ fn copy_self_contained_objects(
|
|||
/// Resolves standard library crates for `Std::run_make` for any build kind (like check, build, clippy, etc.).
|
||||
pub fn std_crates_for_run_make(run: &RunConfig<'_>) -> Vec<String> {
|
||||
// FIXME: Extend builder tests to cover the `crates` field of `Std` instances.
|
||||
if cfg!(feature = "bootstrap-self-test") {
|
||||
if cfg!(test) {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3152,9 +3152,8 @@ impl Step for Bootstrap {
|
|||
|
||||
let mut cmd = command(&builder.initial_cargo);
|
||||
cmd.arg("test")
|
||||
.args(["--features", "bootstrap-self-test"])
|
||||
.current_dir(builder.src.join("src/bootstrap"))
|
||||
.env("RUSTFLAGS", "-Cdebuginfo=2")
|
||||
.env("RUSTFLAGS", "--cfg test -Cdebuginfo=2")
|
||||
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
|
||||
.env("RUSTC_BOOTSTRAP", "1")
|
||||
.env("RUSTDOC", builder.rustdoc(compiler))
|
||||
|
|
|
|||
|
|
@ -1441,7 +1441,7 @@ impl Config {
|
|||
// Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
|
||||
// but not if `config.toml` hasn't been created.
|
||||
let mut toml = if !using_default_path || toml_path.exists() {
|
||||
config.config = Some(if cfg!(not(feature = "bootstrap-self-test")) {
|
||||
config.config = Some(if cfg!(not(test)) {
|
||||
toml_path.canonicalize().unwrap()
|
||||
} else {
|
||||
toml_path.clone()
|
||||
|
|
@ -2793,11 +2793,11 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bootstrap-self-test")]
|
||||
#[cfg(test)]
|
||||
pub fn check_stage0_version(&self, _program_path: &Path, _component_name: &'static str) {}
|
||||
|
||||
/// check rustc/cargo version is same or lower with 1 apart from the building one
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
pub fn check_stage0_version(&self, program_path: &Path, component_name: &'static str) {
|
||||
use build_helper::util::fail;
|
||||
|
||||
|
|
@ -2939,7 +2939,7 @@ impl Config {
|
|||
}
|
||||
|
||||
// Fetching the LLVM submodule is unnecessary for self-tests.
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
self.update_submodule("src/llvm-project");
|
||||
|
||||
// Check for untracked changes in `src/llvm-project`.
|
||||
|
|
@ -3014,7 +3014,7 @@ impl Config {
|
|||
|
||||
/// Compares the current `Llvm` options against those in the CI LLVM builder and detects any incompatible options.
|
||||
/// It does this by destructuring the `Llvm` instance to make sure every `Llvm` field is covered and not missing.
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
pub(crate) fn check_incompatible_options_for_ci_llvm(
|
||||
current_config_toml: TomlConfig,
|
||||
ci_config_toml: TomlConfig,
|
||||
|
|
|
|||
|
|
@ -444,14 +444,14 @@ impl Config {
|
|||
cargo_clippy
|
||||
}
|
||||
|
||||
#[cfg(feature = "bootstrap-self-test")]
|
||||
#[cfg(test)]
|
||||
pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
/// NOTE: rustfmt is a completely different toolchain than the bootstrap compiler, so it can't
|
||||
/// reuse target directories or artifacts
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
|
||||
use build_helper::stage0_parser::VersionMetadata;
|
||||
|
||||
|
|
@ -534,10 +534,10 @@ impl Config {
|
|||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "bootstrap-self-test")]
|
||||
#[cfg(test)]
|
||||
pub(crate) fn download_beta_toolchain(&self) {}
|
||||
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
pub(crate) fn download_beta_toolchain(&self) {
|
||||
self.verbose(|| println!("downloading stage0 beta artifacts"));
|
||||
|
||||
|
|
@ -714,10 +714,10 @@ download-rustc = false
|
|||
self.unpack(&tarball, &bin_root, prefix);
|
||||
}
|
||||
|
||||
#[cfg(feature = "bootstrap-self-test")]
|
||||
#[cfg(test)]
|
||||
pub(crate) fn maybe_download_ci_llvm(&self) {}
|
||||
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
pub(crate) fn maybe_download_ci_llvm(&self) {
|
||||
use build_helper::exit;
|
||||
|
||||
|
|
@ -789,7 +789,7 @@ download-rustc = false
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
fn download_ci_llvm(&self, llvm_sha: &str) {
|
||||
let llvm_assertions = self.llvm_assertions;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ use std::path::PathBuf;
|
|||
use std::{env, fs};
|
||||
|
||||
use crate::Build;
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
use crate::builder::Builder;
|
||||
use crate::builder::Kind;
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
use crate::core::build_steps::tool;
|
||||
use crate::core::config::Target;
|
||||
use crate::utils::exec::command;
|
||||
|
|
@ -38,7 +38,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
|
|||
|
||||
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
|
||||
/// from CI (with`llvm.download-ci-llvm` option).
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
const LIBSTDCXX_MIN_VERSION_THRESHOLD: usize = 8;
|
||||
|
||||
impl Finder {
|
||||
|
|
@ -106,7 +106,7 @@ pub fn check(build: &mut Build) {
|
|||
}
|
||||
|
||||
// Ensure that a compatible version of libstdc++ is available on the system when using `llvm.download-ci-llvm`.
|
||||
#[cfg(not(feature = "bootstrap-self-test"))]
|
||||
#[cfg(not(test))]
|
||||
if !build.config.dry_run() && !build.build.is_msvc() && build.config.llvm_from_ci {
|
||||
let builder = Builder::new(build);
|
||||
let libcxx_version = builder.ensure(tool::LibcxxVersionTool { target: build.build });
|
||||
|
|
@ -226,8 +226,7 @@ than building it.
|
|||
}
|
||||
|
||||
// Ignore fake targets that are only used for unit tests in bootstrap.
|
||||
if cfg!(not(feature = "bootstrap-self-test")) && !skip_target_sanity && !build.local_rebuild
|
||||
{
|
||||
if cfg!(not(test)) && !skip_target_sanity && !build.local_rebuild {
|
||||
let mut has_target = false;
|
||||
let target_str = target.to_string();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue