Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclude to config.toml #137147

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@
# a specific version.
#ccache = false

# List of paths to exclude from the build and test processes.
# For example, exclude = ["tests/ui", "src/tools/tidy"].
#exclude = []

# =============================================================================
# General install configuration options
# =============================================================================
Expand Down
38 changes: 22 additions & 16 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ define_config! {
jobs: Option<u32> = "jobs",
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
ccache: Option<StringOrBool> = "ccache",
exclude: Option<Vec<PathBuf>> = "exclude",
}
}

Expand Down Expand Up @@ -1397,22 +1398,6 @@ impl Config {
"flags.exclude" = ?flags.exclude
);

config.skip = flags
.skip
.into_iter()
.chain(flags.exclude)
.map(|p| {
// Never return top-level path here as it would break `--skip`
// logic on rustc's internal test framework which is utilized
// by compiletest.
if cfg!(windows) {
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
} else {
p
}
})
.collect();

#[cfg(feature = "tracing")]
span!(
target: "CONFIG_HANDLING",
Expand Down Expand Up @@ -1658,8 +1643,29 @@ impl Config {
jobs,
compiletest_diff_tool,
mut ccache,
exclude,
} = toml.build.unwrap_or_default();

let mut paths: Vec<PathBuf> = flags.skip.into_iter().chain(flags.exclude).collect();

if let Some(exclude) = exclude {
paths.extend(exclude);
}

config.skip = paths
.into_iter()
.map(|p| {
// Never return top-level path here as it would break `--skip`
// logic on rustc's internal test framework which is utilized
// by compiletest.
if cfg!(windows) {
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
} else {
p
}
})
.collect();

config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));

if let Some(file_build) = build {
Expand Down
15 changes: 15 additions & 0 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,18 @@ fn test_explicit_stage() {
assert!(!config.explicit_stage_from_config);
assert!(!config.is_explicit_stage());
}

#[test]
fn test_exclude() {
let exclude_path = "compiler";
let config = parse(&format!("build.exclude=[\"{}\"]", exclude_path));

let first_excluded = config
.skip
.first()
.expect("Expected at least one excluded path")
.to_str()
.expect("Failed to convert excluded path to string");

assert_eq!(first_excluded, exclude_path);
}
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "There is now a new `gcc` config section that can be used to download GCC from CI using `gcc.download-ci-gcc = true`",
},
ChangeInfo {
change_id: 137147,
severity: ChangeSeverity::Info,
summary: "New option `build.exclude` that adds support for excluding test.",
},
];
Loading