Skip to content

Commit 0338a33

Browse files
committed
Add support for excluding tests via config.toml
1 parent 8c39ce5 commit 0338a33

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

config.example.toml

+3
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@
424424
# What custom diff tool to use for displaying compiletest tests.
425425
#compiletest-diff-tool = <none>
426426

427+
# List of tests or directories to exclude from the test suite. For example, exclude = ["tests/assembly", "tests/codegen"];
428+
#exclude = []
429+
427430
# =============================================================================
428431
# General install configuration options
429432
# =============================================================================

src/bootstrap/src/core/builder/mod.rs

+25-5
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,11 @@ impl PathSet {
251251

252252
fn has(&self, needle: &Path, module: Kind) -> bool {
253253
match self {
254-
PathSet::Set(set) => set.iter().any(|p| Self::check(p, needle, module)),
255-
PathSet::Suite(suite) => Self::check(suite, needle, module),
254+
PathSet::Set(set) => set.iter().any(|p| p.path == needle && Self::check(p, needle, module)),
255+
PathSet::Suite(suite) => suite.path == needle && Self::check(suite, needle, module),
256256
}
257257
}
258+
258259

259260
// internal use only
260261
fn check(p: &TaskPath, needle: &Path, module: Kind) -> bool {
@@ -417,13 +418,31 @@ impl StepDescription {
417418
}
418419

419420
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
420-
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
421+
// Helper function to determine if a path is explicitly excluded
422+
let is_path_excluded = |exclude: &PathBuf| {
423+
let exclude_path: &Path = exclude.as_path();
424+
pathset.has(exclude_path, builder.kind)
425+
};
426+
427+
// Check if the path is excluded by the --exclude flags
428+
if builder.config.skip.iter().any(is_path_excluded) {
421429
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
422-
println!("Skipping {pathset:?} because it is excluded");
430+
println!("Skipping {pathset:?} because it is excluded by --exclude flag");
423431
}
424432
return true;
425433
}
426-
434+
435+
// Check if the path is excluded by the exclude field in config.toml
436+
if let Some(ref excludes) = builder.config.exclude {
437+
if excludes.iter().any(is_path_excluded) {
438+
if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
439+
println!("Skipping {pathset:?} because it is excluded by config.toml");
440+
}
441+
return true;
442+
}
443+
}
444+
445+
// Verbose logging if not excluded
427446
if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) {
428447
builder.verbose(|| {
429448
println!(
@@ -432,6 +451,7 @@ impl StepDescription {
432451
)
433452
});
434453
}
454+
435455
false
436456
}
437457

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

+6
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ pub struct Config {
392392

393393
/// Command for visual diff display, e.g. `diff-tool --color=always`.
394394
pub compiletest_diff_tool: Option<String>,
395+
396+
// For excluding tests from the test suite
397+
pub exclude: Option<Vec<PathBuf>>,
395398
}
396399

397400
#[derive(Clone, Debug, Default)]
@@ -924,6 +927,7 @@ define_config! {
924927
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
925928
jobs: Option<u32> = "jobs",
926929
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
930+
exclude: Option<Vec<String>> = "exclude",
927931
}
928932
}
929933

@@ -1564,6 +1568,7 @@ impl Config {
15641568
optimized_compiler_builtins,
15651569
jobs,
15661570
compiletest_diff_tool,
1571+
exclude,
15671572
} = toml.build.unwrap_or_default();
15681573

15691574
config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));
@@ -2245,6 +2250,7 @@ impl Config {
22452250
config.optimized_compiler_builtins =
22462251
optimized_compiler_builtins.unwrap_or(config.channel != "dev");
22472252
config.compiletest_diff_tool = compiletest_diff_tool;
2253+
config.exclude = exclude.map(|excludes| excludes.into_iter().map(PathBuf::from).collect());
22482254

22492255
let download_rustc = config.download_rustc_commit.is_some();
22502256
// See https://github.com/rust-lang/compiler-team/issues/326

0 commit comments

Comments
 (0)