diff --git a/verify-coverage-mutants.fsx b/verify-coverage-mutants.fsx index 08212ef..ed5f988 100644 --- a/verify-coverage-mutants.fsx +++ b/verify-coverage-mutants.fsx @@ -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 - printfn "SURVIVED %s" mutation.Id - false - else - printfn "KILLED %s" mutation.Id - true + 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 + Survived + else + printfn "KILLED %s" mutation.Id + 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 ()