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
|
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 =
|
||||||
|
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
|
printfn "SURVIVED %s" mutation.Id
|
||||||
false
|
Survived
|
||||||
else
|
else
|
||||||
printfn "KILLED %s" mutation.Id
|
printfn "KILLED %s" mutation.Id
|
||||||
true
|
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 ()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue