Introduce --filter

This commit is contained in:
Sven van Heugten 2026-05-12 16:38:47 +02:00
parent de5843a783
commit 9ca9bfd687
No known key found for this signature in database
GPG key ID: D612F88666F4F660

View file

@ -121,12 +121,14 @@ let getMutationCases projectPath =
type Arguments =
| [<MainCommand; ExactlyOnce>] ProjectPath of ProjectPath: string
| Filter of SearchString: string
| ValidateOnly
interface IArgParserTemplate with
member s.Usage =
match s with
| ProjectPath _ -> "path/to/project.csproj|fsproj"
| Filter _ -> "filter down to mutations that contain the given search string"
| ValidateOnly -> "check if the patches apply, but don't run the mutations"
[<EntryPoint>]
@ -137,12 +139,18 @@ let main argv =
let projectPath = parsedArguments.GetResult ProjectPath
let validateOnly = parsedArguments.Contains ValidateOnly
let maybeFilter = parsedArguments.TryGetResult Filter
ensureCleanWorkingDirectory ()
AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> restore ())
for index, mutationCase in getMutationCases projectPath |> Seq.indexed do
let filteredMutations =
getMutationCases projectPath
|> Seq.filter _.Patch.Contains(maybeFilter |> Option.defaultValue "")
|> Seq.indexed
for index, mutationCase in filteredMutations do
Console.ForegroundColor <- ConsoleColor.Green
printf $"MUTATION {index + 1}\n"