Don't consider a failed build as a killed mutant
This commit is contained in:
parent
c2e96604c6
commit
f578ca42cb
1 changed files with 29 additions and 12 deletions
|
|
@ -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 ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue