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