summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-04-07 13:34:01 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-04-07 13:34:01 +0200
commit9a747828feeb3c25e5fe0caedc04a2af10ca3ce2 (patch)
tree8c5d4f90213557b9e4d618dc5afb8ef07fa945af /tests
parentb1b14a5e7b3f4f86fc32ab03c5a1666043a9c383 (diff)
parent796f4e917c9164c456d8152fb7d57d566f6148d2 (diff)
downloadNim-9a747828feeb3c25e5fe0caedc04a2af10ca3ce2.tar.gz
Merge pull request #4049 from arnetheduck/tester-targets
tester: allow filtering tests by target
Diffstat (limited to 'tests')
-rw-r--r--tests/testament/specs.nim9
-rw-r--r--tests/testament/tester.nim10
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index bab17d2cd..3f40a5342 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -107,6 +107,15 @@ proc specDefaults*(result: var TSpec) =
   result.tline = 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 =
   specDefaults(result)
   result.file = filename
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 86e9fbc86..da1c6fc2d 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -33,6 +33,7 @@ Options:
   --print                   also print results to the console
   --failing                 only show failing/ignored tests
   --pedantic                return non-zero status code if there are failures
+  --targets:"c c++ js objc" run tests for specified targets (default: all)
 """ % resultsFile
 
 type
@@ -60,6 +61,8 @@ let
   pegSuccess = peg"'Hint: operation successful'.*"
   pegOfInterest = pegLineError / pegOtherError
 
+var targets = {low(TTarget)..high(TTarget)}
+
 proc callCompiler(cmdTemplate, filename, options: string,
                   target: TTarget): TSpec =
   let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
@@ -275,6 +278,11 @@ proc analyzeAndConsolidateOutput(s: string): string =
 
 proc testSpec(r: var TResults, test: TTest) =
   # 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")
   inc(r.total)
   var expected: TSpec
@@ -394,6 +402,7 @@ proc main() =
   var optPrintResults = false
   var optFailing = false
   var optPedantic = false
+
   var p = initOptParser()
   p.next()
   while p.kind == cmdLongoption:
@@ -401,6 +410,7 @@ proc main() =
     of "print", "verbose": optPrintResults = true
     of "failing": optFailing = true
     of "pedantic": optPedantic = true
+    of "targets": targets = parseTargets(p.val.string)
     else: quit Usage
     p.next()
   if p.kind != cmdArgument: quit Usage