Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 08109d3

Browse files
authoredMar 2, 2025
Rollup merge of rust-lang#137147 - Shourya742:2025-02-16-support-exclude-in-config.toml, r=onur-ozkan
Add exclude to config.toml Closes: rust-lang#35678 r? ``@onur-ozkan``
2 parents fed5666 + 9206960 commit 08109d3

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed
 

‎config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@
425425
# a specific version.
426426
#ccache = false
427427

428+
# List of paths to exclude from the build and test processes.
429+
# For example, exclude = ["tests/ui", "src/tools/tidy"].
430+
#exclude = []
431+
428432
# =============================================================================
429433
# General install configuration options
430434
# =============================================================================

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

+22-16
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ define_config! {
942942
jobs: Option<u32> = "jobs",
943943
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
944944
ccache: Option<StringOrBool> = "ccache",
945+
exclude: Option<Vec<PathBuf>> = "exclude",
945946
}
946947
}
947948

@@ -1372,22 +1373,6 @@ impl Config {
13721373
"flags.exclude" = ?flags.exclude
13731374
);
13741375

1375-
config.skip = flags
1376-
.skip
1377-
.into_iter()
1378-
.chain(flags.exclude)
1379-
.map(|p| {
1380-
// Never return top-level path here as it would break `--skip`
1381-
// logic on rustc's internal test framework which is utilized
1382-
// by compiletest.
1383-
if cfg!(windows) {
1384-
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
1385-
} else {
1386-
p
1387-
}
1388-
})
1389-
.collect();
1390-
13911376
#[cfg(feature = "tracing")]
13921377
span!(
13931378
target: "CONFIG_HANDLING",
@@ -1632,8 +1617,29 @@ impl Config {
16321617
jobs,
16331618
compiletest_diff_tool,
16341619
mut ccache,
1620+
exclude,
16351621
} = toml.build.unwrap_or_default();
16361622

1623+
let mut paths: Vec<PathBuf> = flags.skip.into_iter().chain(flags.exclude).collect();
1624+
1625+
if let Some(exclude) = exclude {
1626+
paths.extend(exclude);
1627+
}
1628+
1629+
config.skip = paths
1630+
.into_iter()
1631+
.map(|p| {
1632+
// Never return top-level path here as it would break `--skip`
1633+
// logic on rustc's internal test framework which is utilized
1634+
// by compiletest.
1635+
if cfg!(windows) {
1636+
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
1637+
} else {
1638+
p
1639+
}
1640+
})
1641+
.collect();
1642+
16371643
config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));
16381644

16391645
if let Some(file_build) = build {

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

+14
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,17 @@ 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 config = parse("build.exclude=[\"test/codegen\"]");
522+
523+
let first_excluded = config
524+
.skip
525+
.first()
526+
.expect("Expected at least one excluded path")
527+
.to_str()
528+
.expect("Failed to convert excluded path to string");
529+
530+
assert_eq!(first_excluded, "test/codegen");
531+
}

‎src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
365365
severity: ChangeSeverity::Info,
366366
summary: "`rust.channel` now supports \"auto-detect\" to load the channel from `src/ci/channel`",
367367
},
368+
ChangeInfo {
369+
change_id: 137147,
370+
severity: ChangeSeverity::Info,
371+
summary: "New option `build.exclude` that adds support for excluding test.",
372+
},
368373
];

0 commit comments

Comments
 (0)
Failed to load comments.