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) =
|
||||
## Executes all tests starting with 't' in the ``tests`` directory.
|
||||
## Subdirectories are not walked.
|
||||
var files = toSeq(walkDir(getCurrentDir() / "tests"))
|
||||
var
|
||||
files = toSeq(walkDir(getCurrentDir() / "tests"))
|
||||
tests, failures: int
|
||||
|
||||
if files.len < 1:
|
||||
display("Warning:", "No tests found!", Warning, HighPriority)
|
||||
|
|
@ -1014,7 +1016,14 @@ proc test(options: Options) =
|
|||
binFileName = file.path.changeFileExt(ExeExt)
|
||||
existsBefore = existsFile(binFileName)
|
||||
|
||||
execBackend(optsCopy)
|
||||
if options.continueTestsOnFailure:
|
||||
inc tests
|
||||
try:
|
||||
execBackend(optsCopy)
|
||||
except NimbleError:
|
||||
inc failures
|
||||
else:
|
||||
execBackend(optsCopy)
|
||||
|
||||
let
|
||||
existsAfter = existsFile(binFileName)
|
||||
|
|
@ -1022,7 +1031,11 @@ proc test(options: Options) =
|
|||
if canRemove:
|
||||
removeFile(binFileName)
|
||||
|
||||
display("Success:", "All tests passed", Success, HighPriority)
|
||||
if failures == 0:
|
||||
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) =
|
||||
## Validates a package a in the current working directory.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ type
|
|||
showVersion*: bool
|
||||
noColor*: bool
|
||||
disableValidation*: bool
|
||||
continueTestsOnFailure*: bool
|
||||
## Whether packages' repos should always be downloaded with their history.
|
||||
forceFullClone*: bool
|
||||
|
||||
|
|
@ -77,6 +78,7 @@ Commands:
|
|||
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
|
||||
to the Nim compiler.
|
||||
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
|
||||
package. Passes options to the Nim compiler.
|
||||
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:
|
||||
result.action.compileOptions.add(prefix & flag & ":" & val)
|
||||
of actionCustom:
|
||||
if result.action.command.normalize == "test":
|
||||
if f == "continue" or f == "c":
|
||||
result.continueTestsOnFailure = true
|
||||
result.action.flags[flag] = val
|
||||
else:
|
||||
wasFlagHandled = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue