Merge pull request #647 from jrfondren/continue-tests-on-error
Option to continue tests on failure
This commit is contained in:
commit
f17eaef795
2 changed files with 21 additions and 3 deletions
|
|
@ -992,7 +992,9 @@ proc develop(options: Options) =
|
||||||
proc test(options: Options) =
|
proc test(options: Options) =
|
||||||
## Executes all tests starting with 't' in the ``tests`` directory.
|
## Executes all tests starting with 't' in the ``tests`` directory.
|
||||||
## Subdirectories are not walked.
|
## Subdirectories are not walked.
|
||||||
var files = toSeq(walkDir(getCurrentDir() / "tests"))
|
var
|
||||||
|
files = toSeq(walkDir(getCurrentDir() / "tests"))
|
||||||
|
tests, failures: int
|
||||||
|
|
||||||
if files.len < 1:
|
if files.len < 1:
|
||||||
display("Warning:", "No tests found!", Warning, HighPriority)
|
display("Warning:", "No tests found!", Warning, HighPriority)
|
||||||
|
|
@ -1014,6 +1016,13 @@ proc test(options: Options) =
|
||||||
binFileName = file.path.changeFileExt(ExeExt)
|
binFileName = file.path.changeFileExt(ExeExt)
|
||||||
existsBefore = existsFile(binFileName)
|
existsBefore = existsFile(binFileName)
|
||||||
|
|
||||||
|
if options.continueTestsOnFailure:
|
||||||
|
inc tests
|
||||||
|
try:
|
||||||
|
execBackend(optsCopy)
|
||||||
|
except NimbleError:
|
||||||
|
inc failures
|
||||||
|
else:
|
||||||
execBackend(optsCopy)
|
execBackend(optsCopy)
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
@ -1022,7 +1031,11 @@ proc test(options: Options) =
|
||||||
if canRemove:
|
if canRemove:
|
||||||
removeFile(binFileName)
|
removeFile(binFileName)
|
||||||
|
|
||||||
|
if failures == 0:
|
||||||
display("Success:", "All tests passed", Success, HighPriority)
|
display("Success:", "All tests passed", Success, HighPriority)
|
||||||
|
else:
|
||||||
|
let error = "Only " & $(tests - failures) & "/" & $tests & " tests passed"
|
||||||
|
display("Error:", error, Error, HighPriority)
|
||||||
|
|
||||||
proc check(options: Options) =
|
proc check(options: Options) =
|
||||||
## Validates a package a in the current working directory.
|
## Validates a package a in the current working directory.
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ type
|
||||||
showVersion*: bool
|
showVersion*: bool
|
||||||
noColor*: bool
|
noColor*: bool
|
||||||
disableValidation*: bool
|
disableValidation*: bool
|
||||||
|
continueTestsOnFailure*: bool
|
||||||
## Whether packages' repos should always be downloaded with their history.
|
## Whether packages' repos should always be downloaded with their history.
|
||||||
forceFullClone*: bool
|
forceFullClone*: bool
|
||||||
|
|
||||||
|
|
@ -77,6 +78,7 @@ Commands:
|
||||||
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
|
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
|
||||||
to the Nim compiler.
|
to the Nim compiler.
|
||||||
test Compiles and executes tests
|
test Compiles and executes tests
|
||||||
|
[-c, --continue] Don't stop execution on a failed test.
|
||||||
doc, doc2 [opts, ...] f.nim Builds documentation for a file inside a
|
doc, doc2 [opts, ...] f.nim Builds documentation for a file inside a
|
||||||
package. Passes options to the Nim compiler.
|
package. Passes options to the Nim compiler.
|
||||||
refresh [url] Refreshes the package list. A package list URL
|
refresh [url] Refreshes the package list. A package list URL
|
||||||
|
|
@ -316,6 +318,9 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
||||||
else:
|
else:
|
||||||
result.action.compileOptions.add(prefix & flag & ":" & val)
|
result.action.compileOptions.add(prefix & flag & ":" & val)
|
||||||
of actionCustom:
|
of actionCustom:
|
||||||
|
if result.action.command.normalize == "test":
|
||||||
|
if f == "continue" or f == "c":
|
||||||
|
result.continueTestsOnFailure = true
|
||||||
result.action.flags[flag] = val
|
result.action.flags[flag] = val
|
||||||
else:
|
else:
|
||||||
wasFlagHandled = false
|
wasFlagHandled = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue