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