Skip to content

Commit b8c51f4

Browse files
authored
Rollup merge of #137147 - Shourya742:2025-02-16-support-exclude-in-config.toml, r=onur-ozkan
Add exclude to config.toml Closes: #35678 r? `@onur-ozkan` try-job: x86_64-msvc-2
2 parents 4946818 + c6ecd8c commit b8c51f4

File tree

4 files changed

+46
-16
lines changed

4 files changed

+46
-16
lines changed

config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@
446446
# a specific version.
447447
#ccache = false
448448

449+
# List of paths to exclude from the build and test processes.
450+
# For example, exclude = ["tests/ui", "src/tools/tidy"].
451+
#exclude = []
452+
449453
# =============================================================================
450454
# General install configuration options
451455
# =============================================================================

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

+22-16
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ define_config! {
959959
jobs: Option<u32> = "jobs",
960960
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
961961
ccache: Option<StringOrBool> = "ccache",
962+
exclude: Option<Vec<PathBuf>> = "exclude",
962963
}
963964
}
964965

@@ -1397,22 +1398,6 @@ impl Config {
13971398
"flags.exclude" = ?flags.exclude
13981399
);
13991400

1400-
config.skip = flags
1401-
.skip
1402-
.into_iter()
1403-
.chain(flags.exclude)
1404-
.map(|p| {
1405-
// Never return top-level path here as it would break `--skip`
1406-
// logic on rustc's internal test framework which is utilized
1407-
// by compiletest.
1408-
if cfg!(windows) {
1409-
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
1410-
} else {
1411-
p
1412-
}
1413-
})
1414-
.collect();
1415-
14161401
#[cfg(feature = "tracing")]
14171402
span!(
14181403
target: "CONFIG_HANDLING",
@@ -1658,8 +1643,29 @@ impl Config {
16581643
jobs,
16591644
compiletest_diff_tool,
16601645
mut ccache,
1646+
exclude,
16611647
} = toml.build.unwrap_or_default();
16621648

1649+
let mut paths: Vec<PathBuf> = flags.skip.into_iter().chain(flags.exclude).collect();
1650+
1651+
if let Some(exclude) = exclude {
1652+
paths.extend(exclude);
1653+
}
1654+
1655+
config.skip = paths
1656+
.into_iter()
1657+
.map(|p| {
1658+
// Never return top-level path here as it would break `--skip`
1659+
// logic on rustc's internal test framework which is utilized
1660+
// by compiletest.
1661+
if cfg!(windows) {
1662+
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
1663+
} else {
1664+
p
1665+
}
1666+
})
1667+
.collect();
1668+
16631669
config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));
16641670

16651671
if let Some(file_build) = build {

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

+15
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,18 @@ fn test_explicit_stage() {
515515
assert!(!config.explicit_stage_from_config);
516516
assert!(!config.is_explicit_stage());
517517
}
518+
519+
#[test]
520+
fn test_exclude() {
521+
let exclude_path = "compiler";
522+
let config = parse(&format!("build.exclude=[\"{}\"]", exclude_path));
523+
524+
let first_excluded = config
525+
.skip
526+
.first()
527+
.expect("Expected at least one excluded path")
528+
.to_str()
529+
.expect("Failed to convert excluded path to string");
530+
531+
assert_eq!(first_excluded, exclude_path);
532+
}

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
380380
severity: ChangeSeverity::Warning,
381381
summary: "Removed `src/tools/rls` tool as it was deprecated long time ago.",
382382
},
383+
ChangeInfo {
384+
change_id: 137147,
385+
severity: ChangeSeverity::Info,
386+
summary: "New option `build.exclude` that adds support for excluding test.",
387+
},
383388
];

0 commit comments

Comments
 (0)