diff --git a/doc/testament.rst b/doc/testament.rst index 1a1909022855..253afb33dffb 100644 --- a/doc/testament.rst +++ b/doc/testament.rst @@ -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 diff --git a/testament/specs.nim b/testament/specs.nim index e15dcb85c213..a7f0fd4bbe31 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) diff --git a/tests/align/talign.nim b/tests/align/talign.nim index e0503cc70b8b..3b8f6b4dfbbc 100644 --- a/tests/align/talign.nim +++ b/tests/align/talign.nim @@ -1,6 +1,6 @@ discard """ ccodeCheck: "\\i @'NIM_ALIGN(128) NI mylocal1' .*" -target: "c cpp" +targets: "c cpp" output: "align ok" """ diff --git a/tests/arc/trtree.nim b/tests/arc/trtree.nim index 986268f5160d..5659a5bdcf99 100644 --- a/tests/arc/trtree.nim +++ b/tests/arc/trtree.nim @@ -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" diff --git a/tests/ccgbugs/tmissingvolatile.nim b/tests/ccgbugs/tmissingvolatile.nim index 60b1771dc744..1eccdc6b1b04 100644 --- a/tests/ccgbugs/tmissingvolatile.nim +++ b/tests/ccgbugs/tmissingvolatile.nim @@ -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 diff --git a/tests/ccgbugs/tprogmem.nim b/tests/ccgbugs/tprogmem.nim index 884ca158abcb..58a20583a694 100644 --- a/tests/ccgbugs/tprogmem.nim +++ b/tests/ccgbugs/tprogmem.nim @@ -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] diff --git a/tests/ccgbugs2/tinefficient_const_table.nim b/tests/ccgbugs2/tinefficient_const_table.nim index a1b89e220730..8ab895cb08d2 100644 --- a/tests/ccgbugs2/tinefficient_const_table.nim +++ b/tests/ccgbugs2/tinefficient_const_table.nim @@ -6,7 +6,7 @@ of words''' cmd: r"nim c --hints:on $options -d:release $file" ccodecheck: "! @'genericSeqAssign'" - target: "c" + targets: "c" """ # bug #4354 diff --git a/tests/closure/tclosure.nim b/tests/closure/tclosure.nim index 7e2ec7a77e81..546d7026dd17 100644 --- a/tests/closure/tclosure.nim +++ b/tests/closure/tclosure.nim @@ -1,5 +1,5 @@ discard """ - target: "c" + targets: "c" output: ''' 1 3 6 11 20 foo foo88 diff --git a/tests/compiler/tcppCompileToNamespace.nim b/tests/compiler/tcppCompileToNamespace.nim index 1d0977236434..4e895c38b7a4 100644 --- a/tests/compiler/tcppCompileToNamespace.nim +++ b/tests/compiler/tcppCompileToNamespace.nim @@ -1,6 +1,5 @@ discard """ cmd: "nim cpp --cppCompileToNamespace:foo $options -r $file" -target: cpp """ # Theoretically nim could just ignore the flag cppCompileToNamespace diff --git a/tests/coroutines/texceptions.nim b/tests/coroutines/texceptions.nim index 7b5d57ec0b7b..31feffdff92a 100644 --- a/tests/coroutines/texceptions.nim +++ b/tests/coroutines/texceptions.nim @@ -1,5 +1,5 @@ discard """ - target: "c" + targets: "c" disabled: true """ diff --git a/tests/coroutines/tgc.nim b/tests/coroutines/tgc.nim index 46f4f8e838f0..311ec5efc468 100644 --- a/tests/coroutines/tgc.nim +++ b/tests/coroutines/tgc.nim @@ -1,5 +1,5 @@ discard """ - target: "c" + targets: "c" """ import coro diff --git a/tests/coroutines/titerators.nim b/tests/coroutines/titerators.nim index d12a5debec90..1ea134811d8c 100644 --- a/tests/coroutines/titerators.nim +++ b/tests/coroutines/titerators.nim @@ -1,5 +1,5 @@ discard """ - target: "c" + targets: "c" disabled: true """ diff --git a/tests/coroutines/twait.nim b/tests/coroutines/twait.nim index b88801869cd8..348007afbf42 100644 --- a/tests/coroutines/twait.nim +++ b/tests/coroutines/twait.nim @@ -1,6 +1,6 @@ discard """ output: "Exit 1\nExit 2" - target: "c" + targets: "c" """ import coro diff --git a/tests/cpp/tevalorder.nim b/tests/cpp/tevalorder.nim index f130cef6c7d8..4764f3acabfd 100644 --- a/tests/cpp/tevalorder.nim +++ b/tests/cpp/tevalorder.nim @@ -2,7 +2,7 @@ discard """ output: '''0 1 2''' -target: "cpp" +targets: "cpp" """ # bug #8202 diff --git a/tests/destructor/tmove_objconstr.nim b/tests/destructor/tmove_objconstr.nim index 16d0daa22500..5faaabb8b0e3 100644 --- a/tests/destructor/tmove_objconstr.nim +++ b/tests/destructor/tmove_objconstr.nim @@ -8,7 +8,7 @@ test destroyed 0 4 Pony is dying!''' joinable: false -target: "C" +targets: "c" """ # bug #4214 diff --git a/tests/destructor/tuse_result_prevents_sinks.nim b/tests/destructor/tuse_result_prevents_sinks.nim index 6eac5c902651..d2777bd97692 100644 --- a/tests/destructor/tuse_result_prevents_sinks.nim +++ b/tests/destructor/tuse_result_prevents_sinks.nim @@ -1,6 +1,6 @@ discard """ output: "" - target: "C" + targets: "c" """ # bug #9594 diff --git a/tests/exception/t9657.nim b/tests/exception/t9657.nim index 514d29353abf..6ac525a70bae 100644 --- a/tests/exception/t9657.nim +++ b/tests/exception/t9657.nim @@ -1,7 +1,7 @@ discard """ action: run exitcode: 1 - target: "c cpp" + targets: "c cpp" disabled: "openbsd" disabled: "netbsd" """ diff --git a/tests/flags/tgenscript.nim b/tests/flags/tgenscript.nim index bf83ab972def..d58395a40e26 100644 --- a/tests/flags/tgenscript.nim +++ b/tests/flags/tgenscript.nim @@ -1,5 +1,5 @@ discard """ - target: "c" + targets: "c" action: compile """ diff --git a/tests/iter/titervaropenarray.nim b/tests/iter/titervaropenarray.nim index 4469fdcf55fe..ad1192bd80ff 100644 --- a/tests/iter/titervaropenarray.nim +++ b/tests/iter/titervaropenarray.nim @@ -1,6 +1,6 @@ discard """ output: "123" - targets: "C" + targets: "c" """ # Try to break the transformation pass: iterator iterAndZero(a: var openArray[int]): int = diff --git a/tests/objects/tobjcov.nim b/tests/objects/tobjcov.nim index 6c587e04dd71..a12f74702587 100644 --- a/tests/objects/tobjcov.nim +++ b/tests/objects/tobjcov.nim @@ -1,6 +1,6 @@ discard """ action: compile -target: "c" +targets: "c" """ # Covariance is not type safe: diff --git a/tests/stdlib/t10231.nim b/tests/stdlib/t10231.nim index 2bb64b475c2f..3b2b684f3c16 100644 --- a/tests/stdlib/t10231.nim +++ b/tests/stdlib/t10231.nim @@ -1,5 +1,5 @@ discard """ - target: cpp + targets: "cpp" action: run exitcode: 0 """ diff --git a/tests/stdlib/thashes.nim b/tests/stdlib/thashes.nim index 92154825e763..520b27e26318 100644 --- a/tests/stdlib/thashes.nim +++ b/tests/stdlib/thashes.nim @@ -1,5 +1,5 @@ discard """ - targets: '''c c++ js''' + targets: "c cpp js" """ import hashes diff --git a/tests/stdlib/ttimes.nim b/tests/stdlib/ttimes.nim index 4d89ffa1a48b..a7677edf9638 100644 --- a/tests/stdlib/ttimes.nim +++ b/tests/stdlib/ttimes.nim @@ -1,5 +1,5 @@ discard """ - target: "c js" + targets: "c js" """ import times, strutils, unittest diff --git a/tests/system/tatomics1.nim b/tests/system/tatomics1.nim index 88ab705a8ae7..217fd07fa4c3 100644 --- a/tests/system/tatomics1.nim +++ b/tests/system/tatomics1.nim @@ -1,5 +1,5 @@ discard """ - target: "c cpp js" + targets: "c cpp js" """ var x = 10