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>
This commit is contained in:
Timothee Cour 2020-12-14 01:58:29 -08:00 • committed by GitHub
commit 7e1ae35195
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 33 additions and 39 deletions

View file

@ -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)