fix(xtask): map mutation shards correctly
Translate one-based public shard numbers to mutest's zero-based API, retain requested labels in output paths, and grant compiler-probe tests a 120-second per-mutant floor. Corrected hemx-build shard 1/8 now passes. req: test/022 req: test/023
This commit is contained in:
+10
-6
@@ -1304,7 +1304,8 @@ fn mutation_shard(shard: Option<&str>) -> Result<Option<String>, String> {
|
||||
"invalid mutation shard `{shard}`; require TOTAL >= 2 and 1 <= SHARD <= TOTAL"
|
||||
));
|
||||
}
|
||||
Ok(Some(format!("{index}/{total}")))
|
||||
// mutest numbers shards from zero; xtask presents the conventional 1..=TOTAL surface.
|
||||
Ok(Some(format!("{}/{total}", index - 1)))
|
||||
}
|
||||
|
||||
fn run_mutation_plan(package: Option<&str>, shard: Option<&str>) -> ExitCode {
|
||||
@@ -1315,7 +1316,8 @@ fn run_mutation_plan(package: Option<&str>, shard: Option<&str>) -> ExitCode {
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
};
|
||||
let shard = match mutation_shard(shard) {
|
||||
let requested_shard = shard.map(str::to_owned);
|
||||
let native_shard = match mutation_shard(shard) {
|
||||
Ok(shard) => shard,
|
||||
Err(error) => {
|
||||
eprintln!("{error}");
|
||||
@@ -1337,7 +1339,7 @@ fn run_mutation_plan(package: Option<&str>, shard: Option<&str>) -> ExitCode {
|
||||
|
||||
for package in packages {
|
||||
eprintln!("\n==> mutation: {package}");
|
||||
let output = shard.as_ref().map_or_else(
|
||||
let output = requested_shard.as_ref().map_or_else(
|
||||
|| output_root.join(package),
|
||||
|shard| {
|
||||
output_root
|
||||
@@ -1361,11 +1363,13 @@ fn run_mutation_plan(package: Option<&str>, shard: Option<&str>) -> ExitCode {
|
||||
"--annotations",
|
||||
"none",
|
||||
"--no-times",
|
||||
"--minimum-test-timeout",
|
||||
"120",
|
||||
"--exhaustive",
|
||||
"-o",
|
||||
])
|
||||
.arg(output);
|
||||
if let Some(shard) = &shard {
|
||||
if let Some(shard) = &native_shard {
|
||||
command.args(["--shard", shard]);
|
||||
}
|
||||
let status = command.status();
|
||||
@@ -1628,8 +1632,8 @@ mod tests {
|
||||
assert!(error.contains("hemx-core"));
|
||||
|
||||
assert_eq!(mutation_shard(None).unwrap(), None);
|
||||
assert_eq!(mutation_shard(Some("1/4")).unwrap().as_deref(), Some("1/4"));
|
||||
assert_eq!(mutation_shard(Some("4/4")).unwrap().as_deref(), Some("4/4"));
|
||||
assert_eq!(mutation_shard(Some("1/4")).unwrap().as_deref(), Some("0/4"));
|
||||
assert_eq!(mutation_shard(Some("4/4")).unwrap().as_deref(), Some("3/4"));
|
||||
for invalid in ["1", "a/4", "1/a", "0/4", "5/4", "1/1"] {
|
||||
assert!(
|
||||
mutation_shard(Some(invalid)).unwrap_err().contains(invalid),
|
||||
|
||||
Reference in New Issue
Block a user