fix #14242 testament r tests/js/foo now works; testament now honors --targets (#16163)

* fix #14242 `testament r tests/js/foo` now works; testament now honors --targets

* fix shouldfail
This commit is contained in:
Timothee Cour 2020-11-28 10:33:36 -08:00 • committed by GitHub
commit 1d786c0a54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 30 deletions

View file

@ -81,6 +81,7 @@ let
pegOfInterest = pegLineError / pegOtherError
var gTargets = {low(TTarget)..high(TTarget)}
var targetsSet = false
proc isSuccess(input: string): bool =
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
@ -691,6 +692,7 @@ proc main() =
of "targets":
targetsStr = p.val.string
gTargets = parseTargets(targetsStr)
targetsSet = true
of "nim":
compilerPrefix = addFileExt(p.val.string, ExeExt)
of "directory":
@ -800,14 +802,16 @@ proc main() =
p.next
processPattern(r, pattern, p.cmdLineRest.string, simulate)
of "r", "run":
# "/pathto/tests/stdlib/nre/captures.nim" -> "stdlib" + "tests/stdlib/nre/captures.nim"
var subPath = p.key.string
if subPath.isAbsolute: subPath = subPath.relativePath(getCurrentDir())
let nimRoot = currentSourcePath / "../.."
# makes sure points to this regardless of cwd or which nim is used to compile this.
doAssert existsDir(nimRoot/testsDir) # sanity check
if subPath.isAbsolute: subPath = subPath.relativePath(nimRoot)
# at least one directory is required in the path, to use as a category name
let pathParts = split(subPath, {DirSep, AltSep})
# "stdlib/nre/captures.nim" -> "stdlib" + "nre/captures.nim"
let pathParts = subPath.relativePath(testsDir).split({DirSep, AltSep})
let cat = Category(pathParts[0])
subPath = joinPath(pathParts[1..^1])
processSingleTest(r, cat, p.cmdLineRest.string, subPath)
processSingleTest(r, cat, p.cmdLineRest.string, subPath, gTargets, targetsSet)
of "html":
generateHtml(resultsFile, optFailing)
else: