From 5bcd1477e417a8386a958cb8d8a1d424c9c602e3 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 13 Dec 2020 14:05:24 -0800 Subject: [PATCH 1/7] testament: error instead of silently ignore invalid targets --- testament/specs.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testament/specs.nim b/testament/specs.nim index e15dcb85c213..5b296468b2d5 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -215,10 +215,10 @@ proc parseTargets*(value: string): set[TTarget] = for v in value.normalize.splitWhitespace: case v of "c": result.incl(targetC) - of "cpp", "c++": result.incl(targetCpp) + of "cpp": result.incl(targetCpp) of "objc": result.incl(targetObjC) of "js": result.incl(targetJS) - else: echo "target ignored: " & v + else: doAssert false, "invalid target: '$#'" % v proc addLine*(self: var string; a: string) = self.add a From c342b0a0007570aff7ae88b267ccc153fe8f89e1 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 13 Dec 2020 14:28:24 -0800 Subject: [PATCH 2/7] s/target/targets/ --- doc/testament.rst | 9 ++++++--- testament/specs.nim | 4 ++-- tests/align/talign.nim | 2 +- tests/arc/trtree.nim | 2 +- tests/ccgbugs/tmissingvolatile.nim | 2 +- tests/ccgbugs/tprogmem.nim | 2 +- tests/ccgbugs2/tinefficient_const_table.nim | 2 +- tests/closure/tclosure.nim | 2 +- tests/coroutines/texceptions.nim | 2 +- tests/coroutines/tgc.nim | 2 +- tests/coroutines/titerators.nim | 2 +- tests/coroutines/twait.nim | 2 +- tests/cpp/tevalorder.nim | 2 +- tests/destructor/tmove_objconstr.nim | 2 +- tests/destructor/tuse_result_prevents_sinks.nim | 2 +- tests/exception/t9657.nim | 2 +- tests/flags/tgenscript.nim | 2 +- tests/objects/tobjcov.nim | 2 +- tests/stdlib/thashes.nim | 2 +- tests/stdlib/ttimes.nim | 2 +- tests/system/tatomics1.nim | 2 +- 21 files changed, 27 insertions(+), 24 deletions(-) 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 5b296468b2d5..e5f7cd460cd2 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -382,14 +382,14 @@ proc parseSpec*(filename: string): TSpec = case v of "c": result.targets.incl(targetC) - of "cpp", "c++": + of "cpp": 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 + result.parseErrors.addLine "cannot interpret as a target: '$1'" % v 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..7cf6663270c7 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..52d63e3e2e86 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/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/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/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 From fa2ef2fb79f477270b402cd4849b7a58a9ddadbd Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 13 Dec 2020 14:43:16 -0800 Subject: [PATCH 3/7] DRY --- testament/specs.nim | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/testament/specs.nim b/testament/specs.nim index e5f7cd460cd2..9566d0999916 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -218,7 +218,7 @@ proc parseTargets*(value: string): set[TTarget] = of "cpp": result.incl(targetCpp) of "objc": result.incl(targetObjC) of "js": result.incl(targetJS) - else: doAssert false, "invalid target: '$#'" % 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": - 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: '$1'" % v + of "targets": + 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) From da1c6a65c61c2f66b9894ea24d9b82cbc3322c65 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 13 Dec 2020 16:17:07 -0800 Subject: [PATCH 4/7] fix test; refs #16344 --- tests/compiler/tcppCompileToNamespace.nim | 1 - tests/stdlib/t10231.nim | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) 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/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 """ From 9bb981eac8331f98451064c5e005dbb0ae17d604 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 13 Dec 2020 18:54:23 -0800 Subject: [PATCH 5/7] address comments --- tests/ccgbugs/tmissingvolatile.nim | 2 +- tests/ccgbugs/tprogmem.nim | 2 +- tests/iter/titervaropenarray.nim | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ccgbugs/tmissingvolatile.nim b/tests/ccgbugs/tmissingvolatile.nim index 7cf6663270c7..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;'" - targets: "C" + targets: "c" """ # bug #1539 diff --git a/tests/ccgbugs/tprogmem.nim b/tests/ccgbugs/tprogmem.nim index 52d63e3e2e86..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 = {'" - targets: "C" + targets: "c" """ var myLetVariable {.exportc, codegenDecl: "$# /*PROGMEM*/ $#".} = [1, 2, 3] 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 = From af237615fc8a5018c0acc701ce9c73ce5740c3e6 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 14 Dec 2020 09:59:38 +0100 Subject: [PATCH 6/7] Update testament/specs.nim --- testament/specs.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/specs.nim b/testament/specs.nim index 9566d0999916..667685b41a7e 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -215,7 +215,7 @@ proc parseTargets*(value: string): set[TTarget] = for v in value.normalize.splitWhitespace: case v of "c": result.incl(targetC) - of "cpp": result.incl(targetCpp) + of "cpp", "c++": result.incl(targetCpp) of "objc": result.incl(targetObjC) of "js": result.incl(targetJS) else: raise newException(ValueError, "invalid target: '$#'" % v) From c57a4c7badf0f9ef35d99f3faddc0277a13089e5 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 14 Dec 2020 09:59:44 +0100 Subject: [PATCH 7/7] Update testament/specs.nim --- testament/specs.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testament/specs.nim b/testament/specs.nim index 667685b41a7e..a7f0fd4bbe31 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -377,7 +377,7 @@ proc parseSpec*(filename: string): TSpec = result.timeout = parseFloat(e.value) except ValueError: result.parseErrors.addLine "cannot interpret as a float: ", e.value - of "targets": + of "targets", "target": try: result.targets.incl parseTargets(e.value) except ValueError as e: