summary refs log tree commit diff stats
path: root/testament/testament.nim
diff options
context:
space:
mode:
Diffstat (limited to 'testament/testament.nim')
-rw-r--r--testament/testament.nim27
1 files changed, 24 insertions, 3 deletions
diff --git a/testament/testament.nim b/testament/testament.nim
index e0a200e29..1e892e636 100644
--- a/testament/testament.nim
+++ b/testament/testament.nim
@@ -10,9 +10,12 @@
 ## This program verifies Nim against the testcases.
 
 import
-  strutils, pegs, os, osproc, streams, json, std/exitprocs,
-  backend, parseopt, specs, htmlgen, browsers, terminal,
-  algorithm, times, azure, intsets, macros
+  std/[strutils, pegs, os, osproc, streams, json,
+    parseopt, browsers, terminal, exitprocs,
+    algorithm, times, intsets, macros]
+
+import backend, specs, azure, htmlgen
+
 from std/sugar import dup
 import compiler/nodejs
 import lib/stdtest/testutils
@@ -528,6 +531,23 @@ proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec,
                         "exitcode: " & $given.exitCode & "\n\nOutput:\n" &
                         given.nimout, reExitcodesDiffer)
 
+
+
+proc changeTarget(extraOptions: string; defaultTarget: TTarget): TTarget =
+  result = defaultTarget
+  var p = parseopt.initOptParser(extraOptions)
+
+  while true:
+    parseopt.next(p)
+    case p.kind
+    of cmdEnd: break
+    of cmdLongOption, cmdShortOption:
+      if p.key == "b" or p.key == "backend":
+        result = parseEnum[TTarget](p.val.normalize)
+        # chooses the last one
+    else:
+      discard
+
 proc targetHelper(r: var TResults, test: TTest, expected: TSpec, extraOptions: string) =
   for target in expected.targets:
     inc(r.total)
@@ -540,6 +560,7 @@ proc targetHelper(r: var TResults, test: TTest, expected: TSpec, extraOptions: s
     else:
       let nimcache = nimcacheDir(test.name, test.options, target)
       var testClone = test
+      let target = changeTarget(extraOptions, target)
       testSpecHelper(r, testClone, expected, target, extraOptions, nimcache)
 
 proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =