mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
ccodeCheck: "\\i @'NIM_ALIGN(128) NI mylocal1' .*"
|
||||
target: "c cpp"
|
||||
targets: "c cpp"
|
||||
output: "align ok"
|
||||
"""
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -6,7 +6,7 @@ of
|
||||
words'''
|
||||
cmd: r"nim c --hints:on $options -d:release $file"
|
||||
ccodecheck: "! @'genericSeqAssign'"
|
||||
target: "c"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
# bug #4354
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c"
|
||||
targets: "c"
|
||||
output: '''
|
||||
1 3 6 11 20 foo
|
||||
foo88
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
cmd: "nim cpp --cppCompileToNamespace:foo $options -r $file"
|
||||
target: cpp
|
||||
"""
|
||||
|
||||
# Theoretically nim could just ignore the flag cppCompileToNamespace
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c"
|
||||
targets: "c"
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
import coro
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c"
|
||||
targets: "c"
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
output: "Exit 1\nExit 2"
|
||||
target: "c"
|
||||
targets: "c"
|
||||
"""
|
||||
import coro
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ discard """
|
||||
output: '''0
|
||||
1
|
||||
2'''
|
||||
target: "cpp"
|
||||
targets: "cpp"
|
||||
"""
|
||||
|
||||
# bug #8202
|
||||
|
||||
@@ -8,7 +8,7 @@ test destroyed 0
|
||||
4
|
||||
Pony is dying!'''
|
||||
joinable: false
|
||||
target: "C"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
# bug #4214
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
output: ""
|
||||
target: "C"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
# bug #9594
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
action: run
|
||||
exitcode: 1
|
||||
target: "c cpp"
|
||||
targets: "c cpp"
|
||||
disabled: "openbsd"
|
||||
disabled: "netbsd"
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c"
|
||||
targets: "c"
|
||||
action: compile
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
output: "123"
|
||||
targets: "C"
|
||||
targets: "c"
|
||||
"""
|
||||
# Try to break the transformation pass:
|
||||
iterator iterAndZero(a: var openArray[int]): int =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
action: compile
|
||||
target: "c"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
# Covariance is not type safe:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: cpp
|
||||
targets: "cpp"
|
||||
action: run
|
||||
exitcode: 0
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
targets: '''c c++ js'''
|
||||
targets: "c cpp js"
|
||||
"""
|
||||
|
||||
import hashes
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c js"
|
||||
targets: "c js"
|
||||
"""
|
||||
|
||||
import times, strutils, unittest
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
target: "c cpp js"
|
||||
targets: "c cpp js"
|
||||
"""
|
||||
|
||||
var x = 10
|
||||
|
||||
Reference in New Issue
Block a user