Skip to content

Commit ceb0441

Browse files
committed
Auto merge of rust-lang#134790 - onur-ozkan:cfg-test, r=clubby789
replace bootstrap-self-test feature flag with cfg(test) This makes it in more rusty way.
2 parents 3c1e750 + 485c20d commit ceb0441

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

src/bootstrap/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ default-run = "bootstrap"
77

88
[features]
99
build-metrics = ["sysinfo"]
10-
bootstrap-self-test = [] # enabled in the bootstrap unit tests
1110

1211
[lib]
1312
path = "src/lib.rs"

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ fn copy_self_contained_objects(
396396
/// Resolves standard library crates for `Std::run_make` for any build kind (like check, build, clippy, etc.).
397397
pub fn std_crates_for_run_make(run: &RunConfig<'_>) -> Vec<String> {
398398
// FIXME: Extend builder tests to cover the `crates` field of `Std` instances.
399-
if cfg!(feature = "bootstrap-self-test") {
399+
if cfg!(test) {
400400
return vec![];
401401
}
402402

src/bootstrap/src/core/build_steps/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3152,9 +3152,8 @@ impl Step for Bootstrap {
31523152

31533153
let mut cmd = command(&builder.initial_cargo);
31543154
cmd.arg("test")
3155-
.args(["--features", "bootstrap-self-test"])
31563155
.current_dir(builder.src.join("src/bootstrap"))
3157-
.env("RUSTFLAGS", "-Cdebuginfo=2")
3156+
.env("RUSTFLAGS", "--cfg test -Cdebuginfo=2")
31583157
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
31593158
.env("RUSTC_BOOTSTRAP", "1")
31603159
.env("RUSTDOC", builder.rustdoc(compiler))

src/bootstrap/src/core/config/config.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ impl Config {
14411441
// Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
14421442
// but not if `config.toml` hasn't been created.
14431443
let mut toml = if !using_default_path || toml_path.exists() {
1444-
config.config = Some(if cfg!(not(feature = "bootstrap-self-test")) {
1444+
config.config = Some(if cfg!(not(test)) {
14451445
toml_path.canonicalize().unwrap()
14461446
} else {
14471447
toml_path.clone()
@@ -2793,11 +2793,11 @@ impl Config {
27932793
}
27942794
}
27952795

2796-
#[cfg(feature = "bootstrap-self-test")]
2796+
#[cfg(test)]
27972797
pub fn check_stage0_version(&self, _program_path: &Path, _component_name: &'static str) {}
27982798

27992799
/// check rustc/cargo version is same or lower with 1 apart from the building one
2800-
#[cfg(not(feature = "bootstrap-self-test"))]
2800+
#[cfg(not(test))]
28012801
pub fn check_stage0_version(&self, program_path: &Path, component_name: &'static str) {
28022802
use build_helper::util::fail;
28032803

@@ -2939,7 +2939,7 @@ impl Config {
29392939
}
29402940

29412941
// Fetching the LLVM submodule is unnecessary for self-tests.
2942-
#[cfg(not(feature = "bootstrap-self-test"))]
2942+
#[cfg(not(test))]
29432943
self.update_submodule("src/llvm-project");
29442944

29452945
// Check for untracked changes in `src/llvm-project`.
@@ -3014,7 +3014,7 @@ impl Config {
30143014

30153015
/// Compares the current `Llvm` options against those in the CI LLVM builder and detects any incompatible options.
30163016
/// It does this by destructuring the `Llvm` instance to make sure every `Llvm` field is covered and not missing.
3017-
#[cfg(not(feature = "bootstrap-self-test"))]
3017+
#[cfg(not(test))]
30183018
pub(crate) fn check_incompatible_options_for_ci_llvm(
30193019
current_config_toml: TomlConfig,
30203020
ci_config_toml: TomlConfig,

src/bootstrap/src/core/download.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,14 @@ impl Config {
444444
cargo_clippy
445445
}
446446

447-
#[cfg(feature = "bootstrap-self-test")]
447+
#[cfg(test)]
448448
pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
449449
None
450450
}
451451

452452
/// NOTE: rustfmt is a completely different toolchain than the bootstrap compiler, so it can't
453453
/// reuse target directories or artifacts
454-
#[cfg(not(feature = "bootstrap-self-test"))]
454+
#[cfg(not(test))]
455455
pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
456456
use build_helper::stage0_parser::VersionMetadata;
457457

@@ -534,10 +534,10 @@ impl Config {
534534
);
535535
}
536536

537-
#[cfg(feature = "bootstrap-self-test")]
537+
#[cfg(test)]
538538
pub(crate) fn download_beta_toolchain(&self) {}
539539

540-
#[cfg(not(feature = "bootstrap-self-test"))]
540+
#[cfg(not(test))]
541541
pub(crate) fn download_beta_toolchain(&self) {
542542
self.verbose(|| println!("downloading stage0 beta artifacts"));
543543

@@ -714,10 +714,10 @@ download-rustc = false
714714
self.unpack(&tarball, &bin_root, prefix);
715715
}
716716

717-
#[cfg(feature = "bootstrap-self-test")]
717+
#[cfg(test)]
718718
pub(crate) fn maybe_download_ci_llvm(&self) {}
719719

720-
#[cfg(not(feature = "bootstrap-self-test"))]
720+
#[cfg(not(test))]
721721
pub(crate) fn maybe_download_ci_llvm(&self) {
722722
use build_helper::exit;
723723

@@ -789,7 +789,7 @@ download-rustc = false
789789
};
790790
}
791791

792-
#[cfg(not(feature = "bootstrap-self-test"))]
792+
#[cfg(not(test))]
793793
fn download_ci_llvm(&self, llvm_sha: &str) {
794794
let llvm_assertions = self.llvm_assertions;
795795

src/bootstrap/src/core/sanity.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ use std::path::PathBuf;
1414
use std::{env, fs};
1515

1616
use crate::Build;
17-
#[cfg(not(feature = "bootstrap-self-test"))]
17+
#[cfg(not(test))]
1818
use crate::builder::Builder;
1919
use crate::builder::Kind;
20-
#[cfg(not(feature = "bootstrap-self-test"))]
20+
#[cfg(not(test))]
2121
use crate::core::build_steps::tool;
2222
use crate::core::config::Target;
2323
use crate::utils::exec::command;
@@ -38,7 +38,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
3838

3939
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
4040
/// from CI (with`llvm.download-ci-llvm` option).
41-
#[cfg(not(feature = "bootstrap-self-test"))]
41+
#[cfg(not(test))]
4242
const LIBSTDCXX_MIN_VERSION_THRESHOLD: usize = 8;
4343

4444
impl Finder {
@@ -106,7 +106,7 @@ pub fn check(build: &mut Build) {
106106
}
107107

108108
// Ensure that a compatible version of libstdc++ is available on the system when using `llvm.download-ci-llvm`.
109-
#[cfg(not(feature = "bootstrap-self-test"))]
109+
#[cfg(not(test))]
110110
if !build.config.dry_run() && !build.build.is_msvc() && build.config.llvm_from_ci {
111111
let builder = Builder::new(build);
112112
let libcxx_version = builder.ensure(tool::LibcxxVersionTool { target: build.build });
@@ -226,8 +226,7 @@ than building it.
226226
}
227227

228228
// Ignore fake targets that are only used for unit tests in bootstrap.
229-
if cfg!(not(feature = "bootstrap-self-test")) && !skip_target_sanity && !build.local_rebuild
230-
{
229+
if cfg!(not(test)) && !skip_target_sanity && !build.local_rebuild {
231230
let mut has_target = false;
232231
let target_str = target.to_string();
233232

0 commit comments

Comments
 (0)