Don't consider a failed build as a killed mutant

This commit is contained in:
Sven van Heugten 2026-04-27 22:44:29 +02:00
parent c2e96604c6
commit f578ca42cb
No known key found for this signature in database
GPG key ID: D612F88666F4F660

View file

@ -12,6 +12,11 @@ type MutationCase =
TestName: string
DeclaringType: string }
type MutationOutcome =
| Killed
| Survived
| BuildFailed
type Command =
| List
| Show of string
@ -203,15 +208,26 @@ let runMutation (mutation: MutationCase) =
File.WriteAllText(targetFile, mutatedText)
printfn "==> %s: %s" mutation.Id mutation.TestName
let exitCode = runProcess worktreePath "dotnet" [ "test"; testProjectPath; "--configuration"; options.Configuration; "--filter"; testFilter mutation; "--nologo" ]
File.WriteAllText(targetFile, originalText)
let buildExitCode =
runProcess worktreePath "dotnet" [ "build"; testProjectPath; "--configuration"; options.Configuration; "--nologo" ]
if exitCode = 0 then
let outcome =
if buildExitCode <> 0 then
printfn "BUILD FAILED %s" mutation.Id
BuildFailed
else
let testExitCode =
runProcess worktreePath "dotnet" [ "test"; testProjectPath; "--configuration"; options.Configuration; "--filter"; testFilter mutation; "--no-build"; "--nologo" ]
if testExitCode = 0 then
printfn "SURVIVED %s" mutation.Id
false
Survived
else
printfn "KILLED %s" mutation.Id
true
Killed
File.WriteAllText(targetFile, originalText)
outcome
let mutations = mutationCases ()
@ -234,13 +250,14 @@ match options.Command with
try
createWorktree ()
let killed =
let outcomes =
requested
|> List.map runMutation
let survivors = killed |> List.filter not |> List.length
if survivors = 0 then
let survivors = outcomes |> List.filter ((=) Survived) |> List.length
let buildFailures = outcomes |> List.filter ((=) BuildFailed) |> List.length
if survivors = 0 && buildFailures = 0 then
printfn "All requested mutants were killed."
else
fail $"{survivors} mutant(s) survived."
fail $"{survivors} mutant(s) survived. {buildFailures} mutant(s) failed to build."
finally
cleanup ()