Add build args
This commit is contained in:
parent
544e4366f4
commit
ce48b67d13
1 changed files with 19 additions and 13 deletions
|
|
@ -26,6 +26,7 @@ type Command =
|
|||
type Options =
|
||||
{ Configuration: string
|
||||
ProjectPath: string option
|
||||
BuildArgs: string list
|
||||
NoBuild: bool
|
||||
Command: Command }
|
||||
|
||||
|
|
@ -78,18 +79,19 @@ let repoRoot =
|
|||
stdout.Trim()
|
||||
|
||||
let parseArgs (args: string list) =
|
||||
let rec loop configuration projectPath noBuild remaining =
|
||||
let rec loop configuration projectPath buildArgs noBuild remaining =
|
||||
match remaining with
|
||||
| [] -> { Configuration = configuration; ProjectPath = projectPath; NoBuild = noBuild; Command = Run [] }
|
||||
| "--configuration" :: value :: tail -> loop value projectPath noBuild tail
|
||||
| "--project" :: value :: tail -> loop configuration (Some value) noBuild tail
|
||||
| "--no-build" :: tail -> loop configuration projectPath true tail
|
||||
| "--list" :: tail when tail.IsEmpty -> { Configuration = configuration; ProjectPath = projectPath; NoBuild = noBuild; Command = List }
|
||||
| "--show" :: id :: tail when tail.IsEmpty -> { Configuration = configuration; ProjectPath = projectPath; NoBuild = noBuild; Command = Show id }
|
||||
| "--run" :: tail -> { Configuration = configuration; ProjectPath = projectPath; NoBuild = noBuild; Command = Run tail }
|
||||
| value :: tail when not (value.StartsWith "--") -> { Configuration = configuration; ProjectPath = projectPath; NoBuild = noBuild; Command = Run (value :: tail) }
|
||||
| _ -> fail "Usage: dotnet fsi verify-coverage-mutants.fsx [--project <path/to/project.fsproj>] [--configuration Debug|Release] [--no-build] [--list | --show <id> | --run [id...]]"
|
||||
loop "Debug" None false args
|
||||
| [] -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Run [] }
|
||||
| "--configuration" :: value :: tail -> loop value projectPath buildArgs noBuild tail
|
||||
| "--project" :: value :: tail -> loop configuration (Some value) buildArgs noBuild tail
|
||||
| "--build-arg" :: value :: tail -> loop configuration projectPath (value :: buildArgs) noBuild tail
|
||||
| "--no-build" :: tail -> loop configuration projectPath buildArgs true tail
|
||||
| "--list" :: tail when tail.IsEmpty -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = List }
|
||||
| "--show" :: id :: tail when tail.IsEmpty -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Show id }
|
||||
| "--run" :: tail -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Run tail }
|
||||
| value :: tail when not (value.StartsWith "--") -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Run (value :: tail) }
|
||||
| _ -> fail "Usage: dotnet fsi verify-coverage-mutants.fsx [--project <path/to/project.fsproj>] [--configuration Debug|Release] [--build-arg <value> ...] [--no-build] [--list | --show <id> | --run [id...]]"
|
||||
loop "Debug" None [] false args
|
||||
|
||||
let options = parseArgs (fsi.CommandLineArgs |> Array.skip 1 |> Array.toList)
|
||||
|
||||
|
|
@ -127,9 +129,13 @@ let targetPathForProject (workingDirectory: string) (projectPath: string) =
|
|||
|
||||
let assemblyPath = targetPathForProject repoRoot project.AbsoluteProjectPath
|
||||
|
||||
let buildArgs projectPath =
|
||||
[ "build"; projectPath; "--configuration"; options.Configuration; "--nologo" ]
|
||||
@ options.BuildArgs
|
||||
|
||||
let ensureBuilt () =
|
||||
if not options.NoBuild then
|
||||
let exitCode = runProcess repoRoot "dotnet" [ "build"; project.RelativeProjectPath; "--configuration"; options.Configuration; "--nologo" ]
|
||||
let exitCode = runProcess repoRoot "dotnet" (buildArgs project.RelativeProjectPath)
|
||||
if exitCode <> 0 then fail "dotnet build failed."
|
||||
if not (File.Exists assemblyPath) then
|
||||
fail $"Compiled test assembly not found at {assemblyPath}."
|
||||
|
|
@ -239,7 +245,7 @@ let runMutation (mutation: MutationCase) =
|
|||
|
||||
printfn "==> %s: %s" mutation.Id mutation.TestName
|
||||
let buildExitCode =
|
||||
runProcess worktreePath "dotnet" [ "build"; project.RelativeProjectPath; "--configuration"; options.Configuration; "--nologo" ]
|
||||
runProcess worktreePath "dotnet" (buildArgs project.RelativeProjectPath)
|
||||
|
||||
let outcome =
|
||||
if buildExitCode <> 0 then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue