Skip to content

Commit a55c616

Browse files
committed
Auto merge of rust-lang#137147 - Shourya742:2025-02-16-support-exclude-in-config.toml, r=<try>
Add exclude to config.toml Closes: rust-lang#35678 r? `@onur-ozkan` try-job: x86_64-msvc-2
2 parents 2b285cd + d07eb8b commit a55c616

File tree

4 files changed

+46
-16
lines changed

4 files changed

+46
-16
lines changed

Diff for: config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@
436436
# a specific version.
437437
#ccache = false
438438

439+
# List of paths to exclude from the build and test processes.
440+
# For example, exclude = ["tests/ui", "src/tools/tidy"].
441+
#exclude = []
442+
439443
# =============================================================================
440444
# General install configuration options
441445
# =============================================================================

Diff for: src/bootstrap/src/core/config/config.rs

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

@@ -1374,22 +1375,6 @@ impl Config {
13741375
"flags.exclude" = ?flags.exclude
13751376
);
13761377

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

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

16421648
if let Some(file_build) = build {

Diff for: 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+
}

Diff for: src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
370370
severity: ChangeSeverity::Info,
371371
summary: "The rust.description option has moved to build.description and rust.description is now deprecated.",
372372
},
373+
ChangeInfo {
374+
change_id: 137147,
375+
severity: ChangeSeverity::Info,
376+
summary: "New option `build.exclude` that adds support for excluding test.",
377+
},
373378
];

0 commit comments

Comments
 (0)