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
parent 5514b299eb
commit 7e1ae35195
24 changed files with 33 additions and 39 deletions

View File

@@ -152,8 +152,11 @@ Example "template" **to edit** and write a Testament unittest:
# Timeout seconds to run the test. Fractional values are supported.
timeout: 1.5
# Targets to run the test into (C, C++, JavaScript, etc).
target: "c js"
# Targets to run the test into (c, cpp, objc, js).
targets: "c js"
# flags with which to run the test, delimited by `;`
matrix: "; -d:release; -d:caseFoo -d:release"
# Conditions that will skip this test. Use of multiple "disabled" clauses
# is permitted.
@@ -221,7 +224,7 @@ JavaScript tests:
.. code-block:: nim
discard """
target: "js"
targets: "js"
"""
when defined(js):
import jsconsole

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)

View File

@@ -1,6 +1,6 @@
discard """
ccodeCheck: "\\i @'NIM_ALIGN(128) NI mylocal1' .*"
target: "c cpp"
targets: "c cpp"
output: "align ok"
"""

View File

@@ -1,7 +1,7 @@
discard """
output: '''1 [2, 3, 4, 7]
[0, 0]'''
target: "c"
targets: "c"
joinable: false
disabled: 32bit
cmd: "nim c --gc:arc $file"

View File

@@ -2,7 +2,7 @@ discard """
output: "1"
cmd: r"nim c --hints:on $options -d:release $file"
ccodecheck: "'NI volatile state;'"
target: "C"
targets: "c"
"""
# bug #1539

View File

@@ -2,7 +2,7 @@ discard """
output: "5"
cmd: r"nim c --hints:on $options -d:release $file"
ccodecheck: "'/*PROGMEM*/ myLetVariable = {'"
target: "C"
targets: "c"
"""
var myLetVariable {.exportc, codegenDecl: "$# /*PROGMEM*/ $#".} = [1, 2, 3]

View File

@@ -6,7 +6,7 @@ of
words'''
cmd: r"nim c --hints:on $options -d:release $file"
ccodecheck: "! @'genericSeqAssign'"
target: "c"
targets: "c"
"""
# bug #4354

View File

@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
output: '''
1 3 6 11 20 foo
foo88

View File

@@ -1,6 +1,5 @@
discard """
cmd: "nim cpp --cppCompileToNamespace:foo $options -r $file"
target: cpp
"""
# Theoretically nim could just ignore the flag cppCompileToNamespace

View File

@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
disabled: true
"""

View File

@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
"""
import coro

View File

@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
disabled: true
"""

View File

@@ -1,6 +1,6 @@
discard """
output: "Exit 1\nExit 2"
target: "c"
targets: "c"
"""
import coro

View File

@@ -2,7 +2,7 @@ discard """
output: '''0
1
2'''
target: "cpp"
targets: "cpp"
"""
# bug #8202

View File

@@ -8,7 +8,7 @@ test destroyed 0
4
Pony is dying!'''
joinable: false
target: "C"
targets: "c"
"""
# bug #4214

View File

@@ -1,6 +1,6 @@
discard """
output: ""
target: "C"
targets: "c"
"""
# bug #9594

View File

@@ -1,7 +1,7 @@
discard """
action: run
exitcode: 1
target: "c cpp"
targets: "c cpp"
disabled: "openbsd"
disabled: "netbsd"
"""

View File

@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
action: compile
"""

View File

@@ -1,6 +1,6 @@
discard """
output: "123"
targets: "C"
targets: "c"
"""
# Try to break the transformation pass:
iterator iterAndZero(a: var openArray[int]): int =

View File

@@ -1,6 +1,6 @@
discard """
action: compile
target: "c"
targets: "c"
"""
# Covariance is not type safe:

View File

@@ -1,5 +1,5 @@
discard """
target: cpp
targets: "cpp"
action: run
exitcode: 0
"""

View File

@@ -1,5 +1,5 @@
discard """
targets: '''c c++ js'''
targets: "c cpp js"
"""
import hashes

View File

@@ -1,5 +1,5 @@
discard """
target: "c js"
targets: "c js"
"""
import times, strutils, unittest

View File

@@ -1,5 +1,5 @@
discard """
target: "c cpp js"
targets: "c cpp js"
"""
var x = 10