tester: allow filtering tests by target
This commit is contained in:
parent
73e48f9c9c
commit
25abb7c2b6
2 changed files with 19 additions and 0 deletions
|
|
@ -107,6 +107,15 @@ proc specDefaults*(result: var TSpec) =
|
||||||
result.tline = 0
|
result.tline = 0
|
||||||
result.tcolumn = 0
|
result.tcolumn = 0
|
||||||
|
|
||||||
|
proc parseTargets*(value: string): set[TTarget] =
|
||||||
|
for v in value.normalize.split:
|
||||||
|
case v
|
||||||
|
of "c": result.incl(targetC)
|
||||||
|
of "cpp", "c++": result.incl(targetCpp)
|
||||||
|
of "objc": result.incl(targetObjC)
|
||||||
|
of "js": result.incl(targetJS)
|
||||||
|
else: echo "target ignored: " & v
|
||||||
|
|
||||||
proc parseSpec*(filename: string): TSpec =
|
proc parseSpec*(filename: string): TSpec =
|
||||||
specDefaults(result)
|
specDefaults(result)
|
||||||
result.file = filename
|
result.file = filename
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ Options:
|
||||||
--print also print results to the console
|
--print also print results to the console
|
||||||
--failing only show failing/ignored tests
|
--failing only show failing/ignored tests
|
||||||
--pedantic return non-zero status code if there are failures
|
--pedantic return non-zero status code if there are failures
|
||||||
|
--targets:"c c++ js objc" run tests for specified targets (default: all)
|
||||||
""" % resultsFile
|
""" % resultsFile
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -60,6 +61,8 @@ let
|
||||||
pegSuccess = peg"'Hint: operation successful'.*"
|
pegSuccess = peg"'Hint: operation successful'.*"
|
||||||
pegOfInterest = pegLineError / pegOtherError
|
pegOfInterest = pegLineError / pegOtherError
|
||||||
|
|
||||||
|
var targets = {low(TTarget)..high(TTarget)}
|
||||||
|
|
||||||
proc callCompiler(cmdTemplate, filename, options: string,
|
proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
target: TTarget): TSpec =
|
target: TTarget): TSpec =
|
||||||
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||||
|
|
@ -275,6 +278,11 @@ proc analyzeAndConsolidateOutput(s: string): string =
|
||||||
|
|
||||||
proc testSpec(r: var TResults, test: TTest) =
|
proc testSpec(r: var TResults, test: TTest) =
|
||||||
# major entry point for a single test
|
# major entry point for a single test
|
||||||
|
if test.target notin targets:
|
||||||
|
r.addResult(test, "", "", reIgnored)
|
||||||
|
inc(r.skipped)
|
||||||
|
return
|
||||||
|
|
||||||
let tname = test.name.addFileExt(".nim")
|
let tname = test.name.addFileExt(".nim")
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
var expected: TSpec
|
var expected: TSpec
|
||||||
|
|
@ -394,6 +402,7 @@ proc main() =
|
||||||
var optPrintResults = false
|
var optPrintResults = false
|
||||||
var optFailing = false
|
var optFailing = false
|
||||||
var optPedantic = false
|
var optPedantic = false
|
||||||
|
|
||||||
var p = initOptParser()
|
var p = initOptParser()
|
||||||
p.next()
|
p.next()
|
||||||
while p.kind == cmdLongoption:
|
while p.kind == cmdLongoption:
|
||||||
|
|
@ -401,6 +410,7 @@ proc main() =
|
||||||
of "print", "verbose": optPrintResults = true
|
of "print", "verbose": optPrintResults = true
|
||||||
of "failing": optFailing = true
|
of "failing": optFailing = true
|
||||||
of "pedantic": optPedantic = true
|
of "pedantic": optPedantic = true
|
||||||
|
of "targets": targets = parseTargets(p.val)
|
||||||
else: quit Usage
|
else: quit Usage
|
||||||
p.next()
|
p.next()
|
||||||
if p.kind != cmdArgument: quit Usage
|
if p.kind != cmdArgument: quit Usage
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue