Skip to content

Commit b8ead87

Browse files
committed
change profile for coverage runs
1 parent da86e0c commit b8ead87

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ codegen-units = 8
105105
incremental = false
106106
debug = false
107107

108+
[profile.ephemeral-coverage]
109+
inherits = "ephemeral-build"
110+
debug = true
111+
108112
[profile.release-with-debug]
109113
inherits = "release"
110114
debug = true

crates/xtask/src/main.rs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,13 @@ impl GlobalArgs {
346346
}
347347
}
348348

349+
pub fn without_coverage(self) -> Self {
350+
Self {
351+
coverage: false,
352+
..self
353+
}
354+
}
355+
349356
pub fn with_features(self, features: Features) -> Self {
350357
Self { features, ..self }
351358
}
@@ -514,7 +521,7 @@ impl Xtasks {
514521
output.sort_by(|e1, e2| e1.subcmd.cmp(&e2.subcmd));
515522
let mut rows = Vec::default();
516523
for os in &["ubuntu-latest", "macos-latest", "windows-latest"] {
517-
for row in output.iter_mut() {
524+
for row in output.iter() {
518525
let is_main_os = os == &"ubuntu-latest";
519526
let step_should_run_on_main_os =
520527
matches!(row.subcmd, Xtasks::Build | Xtasks::Docs { .. });
@@ -525,11 +532,17 @@ impl Xtasks {
525532
}
526533

527534
// we only need one source of coverage + windows is slow with this setting
528-
if !is_main_os && is_coverage_step {
529-
row.global_args.coverage = false;
530-
}
535+
let row = if !is_main_os && is_coverage_step {
536+
let new_args = row.global_args.clone().without_coverage();
537+
App {
538+
global_args: new_args,
539+
..row.clone()
540+
}
541+
.into_ci_row(os.to_string())
542+
} else {
543+
row.clone().into_ci_row(os.to_string())
544+
};
531545

532-
let row = row.clone().into_ci_row(os.to_string());
533546
rows.push(row);
534547
}
535548
}
@@ -611,7 +624,12 @@ impl Xtasks {
611624
add_args: I,
612625
dir: Option<&Path>,
613626
) -> Result<()> {
614-
info!("Running workspace command: {}", command);
627+
let coverage_mode = app_settings
628+
.coverage
629+
.then_some("with coverage")
630+
.unwrap_or_default();
631+
632+
info!("Running workspace command {coverage_mode}: {command}");
615633

616634
let mut args = vec![];
617635
args.push(command.to_owned());
@@ -622,8 +640,18 @@ impl Xtasks {
622640
args.push("--workspace".to_owned());
623641

624642
if let Some(profile) = app_settings.profile.as_ref() {
625-
args.push("--profile".to_owned());
626-
args.push(profile.clone());
643+
let use_profile = if profile == "ephemeral-build" && app_settings.coverage {
644+
// use special profile for coverage as it needs debug information
645+
// but also don't want it too slow
646+
"ephemeral-coverage"
647+
} else {
648+
profile
649+
};
650+
651+
if !app_settings.coverage {
652+
args.push("--profile".to_owned());
653+
args.push(use_profile.to_owned());
654+
}
627655
}
628656

629657
args.extend(app_settings.features.to_cargo_args());

0 commit comments

Comments
 (0)