Skip to content

Commit d12e035

Browse files
authored
Unrolled build for rust-lang#139660
Rollup merge of rust-lang#139660 - Zalathar:new-executor, r=jieyouxu compiletest: Add an experimental new executor to replace libtest This PR adds a new "executor" to compiletest for running the list of collected tests, to eventually replace the current dependency on unstable libtest internals. The new executor is currently inactive by default. It must be activated explicitly by passing `-n` or `--new-executor` to compiletest, e.g. `./x test ui -- -n`. (After some amount of wider manual testing, the new executor will hopefully be made the default, and the libtest dependency can be removed. Contributors should not notice any change.) The new executor is a stripped-down rewrite of the subset of libtest needed by compiletest. # Supported functionality - Specifying the number of concurrent tests with `RUST_TEST_THREADS` - Filtering and skipping tests by name (substring or exact-match) - Forcibly running ignored tests with `--ignored` - Optional fail-fast with `--fail-fast` - JSON output, compatible with bootstrap's parser for libtest output - Running each test in its own thread - Short backtraces that ignore the executor itself - Slow test detection, with a hard-coded timeout of 60 seconds - Capturing stdout/stderr, via `#![feature(internal_output_capture)]` - Suppressing output capture with `--no-capture` # Unsupported functionality - Non-JSON output, as this is handled by bootstrap instead - Separate code path for concurrency=1, as the concurrent path should handle this case naturally - Fallback to running tests synchronously if new threads can't be spawned - Special handling of hosts that don't support basic functionality like threads or timers - Our ability to test *targets* should be unaffected - Graceful handling of some edge cases that could occur in arbitrary user-written unit tests, but would represent bugs in compiletest - Due to the current need for output capture, the new executor is still not entirely written in stable Rust --- r? jieyouxu
2 parents 58c2dd9 + e3d6813 commit d12e035

File tree

9 files changed

+574
-117
lines changed

9 files changed

+574
-117
lines changed

Diff for: src/bootstrap/src/core/build_steps/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::core::build_steps::compile::{
44
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_run_make,
55
};
6-
use crate::core::build_steps::tool::{SourceType, prepare_tool_cargo};
6+
use crate::core::build_steps::tool::{COMPILETEST_ALLOW_FEATURES, SourceType, prepare_tool_cargo};
77
use crate::core::builder::{
88
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, crate_description,
99
};
@@ -416,7 +416,7 @@ impl Step for Compiletest {
416416
&[],
417417
);
418418

419-
cargo.allow_features("test");
419+
cargo.allow_features(COMPILETEST_ALLOW_FEATURES);
420420

421421
// For ./x.py clippy, don't run with --all-targets because
422422
// linting tests and benchmarks can produce very noisy results

Diff for: src/bootstrap/src/core/build_steps/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::core::build_steps::doc::DocumentationFormat;
1515
use crate::core::build_steps::gcc::{Gcc, add_cg_gcc_cargo_flags};
1616
use crate::core::build_steps::llvm::get_llvm_version;
1717
use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget;
18-
use crate::core::build_steps::tool::{self, SourceType, Tool};
18+
use crate::core::build_steps::tool::{self, COMPILETEST_ALLOW_FEATURES, SourceType, Tool};
1919
use crate::core::build_steps::toolstate::ToolState;
2020
use crate::core::build_steps::{compile, dist, llvm};
2121
use crate::core::builder::{
@@ -721,7 +721,7 @@ impl Step for CompiletestTest {
721721
SourceType::InTree,
722722
&[],
723723
);
724-
cargo.allow_features("test");
724+
cargo.allow_features(COMPILETEST_ALLOW_FEATURES);
725725
run_cargo_test(cargo, &[], &[], "compiletest self test", host, builder);
726726
}
727727
}

Diff for: src/bootstrap/src/core/build_steps/tool.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ macro_rules! bootstrap_tool {
444444
SourceType::InTree
445445
},
446446
extra_features: vec![],
447-
allow_features: concat!($($allow_features)*),
447+
allow_features: {
448+
let mut _value = "";
449+
$( _value = $allow_features; )?
450+
_value
451+
},
448452
cargo_args: vec![],
449453
artifact_kind: if false $(|| $artifact_kind == ToolArtifactKind::Library)* {
450454
ToolArtifactKind::Library
@@ -458,6 +462,8 @@ macro_rules! bootstrap_tool {
458462
}
459463
}
460464

465+
pub(crate) const COMPILETEST_ALLOW_FEATURES: &str = "test,internal_output_capture";
466+
461467
bootstrap_tool!(
462468
// This is marked as an external tool because it includes dependencies
463469
// from submodules. Trying to keep the lints in sync between all the repos
@@ -468,7 +474,7 @@ bootstrap_tool!(
468474
Tidy, "src/tools/tidy", "tidy";
469475
Linkchecker, "src/tools/linkchecker", "linkchecker";
470476
CargoTest, "src/tools/cargotest", "cargotest";
471-
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true, allow_features = "test";
477+
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true, allow_features = COMPILETEST_ALLOW_FEATURES;
472478
BuildManifest, "src/tools/build-manifest", "build-manifest";
473479
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
474480
RustInstaller, "src/tools/rust-installer", "rust-installer";
@@ -483,7 +489,8 @@ bootstrap_tool!(
483489
GenerateCopyright, "src/tools/generate-copyright", "generate-copyright";
484490
SuggestTests, "src/tools/suggest-tests", "suggest-tests";
485491
GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys";
486-
RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = "test";
492+
// rustdoc-gui-test has a crate dependency on compiletest, so it needs the same unstable features.
493+
RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = COMPILETEST_ALLOW_FEATURES;
487494
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
488495
WasmComponentLd, "src/tools/wasm-component-ld", "wasm-component-ld", is_unstable_tool = true, allow_features = "min_specialization";
489496
UnicodeTableGenerator, "src/tools/unicode-table-generator", "unicode-table-generator";

Diff for: src/tools/compiletest/src/common.rs

+5
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ pub struct Config {
414414
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
415415
/// ABI tests.
416416
pub minicore_path: Utf8PathBuf,
417+
418+
/// If true, run tests with the "new" executor that was written to replace
419+
/// compiletest's dependency on libtest. Eventually this will become the
420+
/// default, and the libtest dependency will be removed.
421+
pub new_executor: bool,
417422
}
418423

419424
impl Config {

0 commit comments

Comments
 (0)