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

@ -563,13 +563,13 @@ proc `&.?`(a, b: string): string =
# candidate for the stdlib? # candidate for the stdlib?
result = if b.startsWith(a): b else: a & b result = if b.startsWith(a): b else: a & b
proc processSingleTest(r: var TResults, cat: Category, options, test: string) = proc processSingleTest(r: var TResults, cat: Category, options, test: string, targets: set[TTarget], targetsSet: bool) =
let test = testsDir &.? cat.string / test var targets = targets
let target = if cat.string.normalize == "js": targetJS else: targetC if not targetsSet:
if fileExists(test): let target = if cat.string.normalize == "js": targetJS else: targetC
testSpec r, makeTest(test, options, cat), {target} targets = {target}
else: doAssert fileExists(test), test & " test does not exist"
doAssert false, test & " test does not exist" testSpec r, makeTest(test, options, cat), targets
proc isJoinableSpec(spec: TSpec): bool = proc isJoinableSpec(spec: TSpec): bool =
result = not spec.sortoutput and result = not spec.sortoutput and

View file

@ -57,10 +57,10 @@ type
reInvalidSpec # test had problems to parse the spec reInvalidSpec # test had problems to parse the spec
TTarget* = enum TTarget* = enum
targetC = "C" targetC = "c"
targetCpp = "C++" targetCpp = "cpp"
targetObjC = "ObjC" targetObjC = "objc"
targetJS = "JS" targetJS = "js"
InlineError* = object InlineError* = object
kind*: string kind*: string

View file

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

View file

@ -2,36 +2,36 @@ discard """
cmd: "testament/testament --directory:testament --colors:off --backendLogging:off --nim:../compiler/nim category shouldfail" cmd: "testament/testament --directory:testament --colors:off --backendLogging:off --nim:../compiler/nim category shouldfail"
action: compile action: compile
nimout: ''' nimout: '''
FAIL: tests/shouldfail/tccodecheck.nim C FAIL: tests/shouldfail/tccodecheck.nim c
Failure: reCodegenFailure Failure: reCodegenFailure
Expected: Expected:
baz baz
FAIL: tests/shouldfail/tcolumn.nim C FAIL: tests/shouldfail/tcolumn.nim c
Failure: reLinesDiffer Failure: reLinesDiffer
FAIL: tests/shouldfail/terrormsg.nim C FAIL: tests/shouldfail/terrormsg.nim c
Failure: reMsgsDiffer Failure: reMsgsDiffer
FAIL: tests/shouldfail/texitcode1.nim C FAIL: tests/shouldfail/texitcode1.nim c
Failure: reExitcodesDiffer Failure: reExitcodesDiffer
FAIL: tests/shouldfail/tfile.nim C FAIL: tests/shouldfail/tfile.nim c
Failure: reFilesDiffer Failure: reFilesDiffer
FAIL: tests/shouldfail/tline.nim C FAIL: tests/shouldfail/tline.nim c
Failure: reLinesDiffer Failure: reLinesDiffer
FAIL: tests/shouldfail/tmaxcodesize.nim C FAIL: tests/shouldfail/tmaxcodesize.nim c
Failure: reCodegenFailure Failure: reCodegenFailure
max allowed size: 1 max allowed size: 1
FAIL: tests/shouldfail/tnimout.nim C FAIL: tests/shouldfail/tnimout.nim c
Failure: reMsgsDiffer Failure: reMsgsDiffer
FAIL: tests/shouldfail/toutput.nim C FAIL: tests/shouldfail/toutput.nim c
Failure: reOutputsDiffer Failure: reOutputsDiffer
FAIL: tests/shouldfail/toutputsub.nim C FAIL: tests/shouldfail/toutputsub.nim c
Failure: reOutputsDiffer Failure: reOutputsDiffer
FAIL: tests/shouldfail/treject.nim C FAIL: tests/shouldfail/treject.nim c
Failure: reFilesDiffer Failure: reFilesDiffer
FAIL: tests/shouldfail/tsortoutput.nim C FAIL: tests/shouldfail/tsortoutput.nim c
Failure: reOutputsDiffer Failure: reOutputsDiffer
FAIL: tests/shouldfail/ttimeout.nim C FAIL: tests/shouldfail/ttimeout.nim c
Failure: reTimeout Failure: reTimeout
FAIL: tests/shouldfail/tvalgrind.nim C FAIL: tests/shouldfail/tvalgrind.nim c
Failure: reExitcodesDiffer Failure: reExitcodesDiffer
''' '''
""" """