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

[WIP] parallel test crates #10052

Closed
wants to merge 25 commits into from
Closed
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
1 change: 1 addition & 0 deletions src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn cli() -> App {
"Exclude packages from the test",
)
.arg_jobs()
.arg_test_jobs()
.arg_release("Build artifacts in release mode, with optimizations")
.arg_profile("Build artifacts with the specified profile")
.arg_features()
Expand Down
8 changes: 8 additions & 0 deletions src/cargo/core/compiler/build_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct BuildConfig {
pub requested_kinds: Vec<CompileKind>,
/// Number of rustc jobs to run in parallel.
pub jobs: u32,
/// Number of crates to test in parallel.
pub test_jobs: u32,
/// Build profile
pub requested_profile: InternedString,
/// The mode we are compiling in.
Expand Down Expand Up @@ -53,6 +55,7 @@ impl BuildConfig {
pub fn new(
config: &Config,
jobs: Option<u32>,
test_jobs: Option<u32>,
requested_targets: &[String],
mode: CompileMode,
) -> CargoResult<BuildConfig> {
Expand All @@ -72,10 +75,15 @@ impl BuildConfig {
if jobs == 0 {
anyhow::bail!("jobs may not be 0");
}
let test_jobs = test_jobs.or(cfg.test_jobs).unwrap_or(1);
if test_jobs == 0 {
anyhow::bail!("test jobs may not be 0");
}

Ok(BuildConfig {
requested_kinds,
jobs,
test_jobs,
requested_profile: InternedString::new("dev"),
mode,
message_format: MessageFormat::Human,
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct CompileOptions {
impl<'a> CompileOptions {
pub fn new(config: &Config, mode: CompileMode) -> CargoResult<CompileOptions> {
Ok(CompileOptions {
build_config: BuildConfig::new(config, None, &[], mode)?,
build_config: BuildConfig::new(config, None, None, &[], mode)?,
cli_features: CliFeatures::new_all(false),
spec: ops::Packages::Packages(Vec::new()),
filter: CompileFilter::Default {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn fetch<'a>(

let jobs = Some(1);
let config = ws.config();
let build_config = BuildConfig::new(config, jobs, &options.targets, CompileMode::Build)?;
let build_config = BuildConfig::new(config, jobs, None, &options.targets, CompileMode::Build)?;
let data = RustcTargetData::new(ws, &build_config.requested_kinds)?;
let mut fetched_packages = HashSet::new();
let mut deps_to_fetch = ws.members().map(|p| p.package_id()).collect::<Vec<_>>();
Expand Down
8 changes: 7 additions & 1 deletion src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,13 @@ fn run_verify(
ops::compile_with_exec(
&ws,
&ops::CompileOptions {
build_config: BuildConfig::new(config, opts.jobs, &opts.targets, CompileMode::Build)?,
build_config: BuildConfig::new(
config,
opts.jobs,
None,
&opts.targets,
CompileMode::Build,
)?,
cli_features: opts.cli_features.clone(),
spec: ops::Packages::Packages(Vec::new()),
filter: ops::CompileFilter::Default {
Expand Down
Loading