summary refs log tree commit diff stats
path: root/testament
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-12-14 01:58:29 -0800
committerGitHub <noreply@github.com>2020-12-14 10:58:29 +0100
commit7e1ae35195c9b1397d569ebb3b3a0d11fdcb16f4 (patch)
tree40648877eb3800ac7f76d4ababf4193c77b7bbd4 /testament
parent5514b299ebc1de4ef0c1c182d4f21a02e3c2fa90 (diff)
downloadNim-7e1ae35195c9b1397d569ebb3b3a0d11fdcb16f4.tar.gz
testament: error instead of silently ignore invalid targets; remove pointless alias target vs targets; document matrix; DRY (#16343)
* testament: error instead of silently ignore invalid targets
* s/target/targets/
* fix test; refs #16344
* address comments
* Update testament/specs.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'testament')
-rw-r--r--testament/specs.nim20
1 files changed, 6 insertions, 14 deletions
diff --git a/testament/specs.nim b/testament/specs.nim
index e15dcb85c..a7f0fd4bb 100644
--- a/testament/specs.nim
+++ b/testament/specs.nim
@@ -218,7 +218,7 @@ proc parseTargets*(value: string): set[TTarget] =
     of "cpp", "c++": result.incl(targetCpp)
     of "objc": result.incl(targetObjC)
     of "js": result.incl(targetJS)
-    else: echo "target ignored: " & v
+    else: raise newException(ValueError, "invalid target: '$#'" % v)
 
 proc addLine*(self: var string; a: string) =
   self.add a
@@ -377,19 +377,11 @@ proc parseSpec*(filename: string): TSpec =
           result.timeout = parseFloat(e.value)
         except ValueError:
           result.parseErrors.addLine "cannot interpret as a float: ", e.value
-      of "target", "targets":
-        for v in e.value.normalize.splitWhitespace:
-          case v
-          of "c":
-            result.targets.incl(targetC)
-          of "cpp", "c++":
-            result.targets.incl(targetCpp)
-          of "objc":
-            result.targets.incl(targetObjC)
-          of "js":
-            result.targets.incl(targetJS)
-          else:
-            result.parseErrors.addLine "cannot interpret as a target: ", e.value
+      of "targets", "target":
+        try:
+          result.targets.incl parseTargets(e.value)
+        except ValueError as e:
+          result.parseErrors.addLine e.msg
       of "matrix":
         for v in e.value.split(';'):
           result.matrix.add(v.strip)