Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testament: error instead of silently ignore invalid targets; remove pointless alias target vs targets; document matrix; DRY #16343

Merged
merged 7 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions doc/testament.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -221,7 +224,7 @@ JavaScript tests:
.. code-block:: nim

discard """
target: "js"
targets: "js"
"""
when defined(js):
import jsconsole
Expand Down
22 changes: 7 additions & 15 deletions testament/specs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Araq marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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":
Araq marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
2 changes: 1 addition & 1 deletion tests/align/talign.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
ccodeCheck: "\\i @'NIM_ALIGN(128) NI mylocal1' .*"
target: "c cpp"
targets: "c cpp"
output: "align ok"
"""

Expand Down
2 changes: 1 addition & 1 deletion tests/arc/trtree.nim
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/ccgbugs/tmissingvolatile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
timotheecour marked this conversation as resolved.
Show resolved Hide resolved
"""

# bug #1539
Expand Down
2 changes: 1 addition & 1 deletion tests/ccgbugs/tprogmem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ discard """
output: "5"
cmd: r"nim c --hints:on $options -d:release $file"
ccodecheck: "'/*PROGMEM*/ myLetVariable = {'"
target: "C"
targets: "C"
timotheecour marked this conversation as resolved.
Show resolved Hide resolved
"""

var myLetVariable {.exportc, codegenDecl: "$# /*PROGMEM*/ $#".} = [1, 2, 3]
Expand Down
2 changes: 1 addition & 1 deletion tests/ccgbugs2/tinefficient_const_table.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ of
words'''
cmd: r"nim c --hints:on $options -d:release $file"
ccodecheck: "! @'genericSeqAssign'"
target: "c"
targets: "c"
"""

# bug #4354
Expand Down
2 changes: 1 addition & 1 deletion tests/closure/tclosure.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
output: '''
1 3 6 11 20 foo
foo88
Expand Down
1 change: 0 additions & 1 deletion tests/compiler/tcppCompileToNamespace.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
discard """
cmd: "nim cpp --cppCompileToNamespace:foo $options -r $file"
target: cpp
"""

# Theoretically nim could just ignore the flag cppCompileToNamespace
Expand Down
2 changes: 1 addition & 1 deletion tests/coroutines/texceptions.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
disabled: true
"""

Expand Down
2 changes: 1 addition & 1 deletion tests/coroutines/tgc.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
"""

import coro
Expand Down
2 changes: 1 addition & 1 deletion tests/coroutines/titerators.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
disabled: true
"""

Expand Down
2 changes: 1 addition & 1 deletion tests/coroutines/twait.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
output: "Exit 1\nExit 2"
target: "c"
targets: "c"
"""
import coro

Expand Down
2 changes: 1 addition & 1 deletion tests/cpp/tevalorder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ discard """
output: '''0
1
2'''
target: "cpp"
targets: "cpp"
"""

# bug #8202
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tmove_objconstr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test destroyed 0
4
Pony is dying!'''
joinable: false
target: "C"
targets: "c"
"""

# bug #4214
Expand Down
2 changes: 1 addition & 1 deletion tests/destructor/tuse_result_prevents_sinks.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
output: ""
target: "C"
targets: "c"
"""

# bug #9594
Expand Down
2 changes: 1 addition & 1 deletion tests/exception/t9657.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
discard """
action: run
exitcode: 1
target: "c cpp"
targets: "c cpp"
disabled: "openbsd"
disabled: "netbsd"
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/flags/tgenscript.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c"
targets: "c"
action: compile
"""

Expand Down
2 changes: 1 addition & 1 deletion tests/objects/tobjcov.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
action: compile
target: "c"
targets: "c"
"""

# Covariance is not type safe:
Expand Down
2 changes: 1 addition & 1 deletion tests/stdlib/t10231.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: cpp
targets: "cpp"
action: run
exitcode: 0
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/stdlib/thashes.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
targets: '''c c++ js'''
targets: "c cpp js"
"""

import hashes
Expand Down
2 changes: 1 addition & 1 deletion tests/stdlib/ttimes.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c js"
targets: "c js"
"""

import times, strutils, unittest
Expand Down
2 changes: 1 addition & 1 deletion tests/system/tatomics1.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
target: "c cpp js"
targets: "c cpp js"
"""

var x = 10
Expand Down