added a testcase for #12195; testament now supports a 'timeout' spec field
This commit is contained in:
parent
f1b7c0494e
commit
c9f3a8b269
5 changed files with 52 additions and 1 deletions
|
|
@ -34,6 +34,7 @@ type
|
||||||
reLinesDiffer, # expected and given line numbers differ
|
reLinesDiffer, # expected and given line numbers differ
|
||||||
reOutputsDiffer,
|
reOutputsDiffer,
|
||||||
reExitcodesDiffer,
|
reExitcodesDiffer,
|
||||||
|
reTimeout,
|
||||||
reInvalidPeg,
|
reInvalidPeg,
|
||||||
reCodegenFailure,
|
reCodegenFailure,
|
||||||
reCodeNotFound,
|
reCodeNotFound,
|
||||||
|
|
@ -70,6 +71,8 @@ type
|
||||||
nimout*: string
|
nimout*: string
|
||||||
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
||||||
unjoinable*: bool
|
unjoinable*: bool
|
||||||
|
timeout*: float # in seconds, fractions possible,
|
||||||
|
# but don't rely on much precision
|
||||||
|
|
||||||
proc getCmd*(s: TSpec): string =
|
proc getCmd*(s: TSpec): string =
|
||||||
if s.cmd.len == 0:
|
if s.cmd.len == 0:
|
||||||
|
|
@ -225,6 +228,11 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.ccodeCheck = e.value
|
result.ccodeCheck = e.value
|
||||||
of "maxcodesize":
|
of "maxcodesize":
|
||||||
discard parseInt(e.value, result.maxCodeSize)
|
discard parseInt(e.value, result.maxCodeSize)
|
||||||
|
of "timeout":
|
||||||
|
try:
|
||||||
|
result.timeout = parseFloat(e.value)
|
||||||
|
except ValueError:
|
||||||
|
result.parseErrors.addLine "cannot interpret as a float: ", e.value
|
||||||
of "target", "targets":
|
of "target", "targets":
|
||||||
for v in e.value.normalize.splitWhitespace:
|
for v in e.value.normalize.splitWhitespace:
|
||||||
case v
|
case v
|
||||||
|
|
|
||||||
|
|
@ -244,13 +244,16 @@ proc `$`(x: TResults): string =
|
||||||
[$x.passed, $x.skipped, $x.total]
|
[$x.passed, $x.skipped, $x.total]
|
||||||
|
|
||||||
proc addResult(r: var TResults, test: TTest, target: TTarget,
|
proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||||
expected, given: string, success: TResultEnum) =
|
expected, given: string, successOrig: TResultEnum) =
|
||||||
# test.name is easier to find than test.name.extractFilename
|
# test.name is easier to find than test.name.extractFilename
|
||||||
# A bit hacky but simple and works with tests/testament/tshouldfail.nim
|
# A bit hacky but simple and works with tests/testament/tshouldfail.nim
|
||||||
var name = test.name.replace(DirSep, '/')
|
var name = test.name.replace(DirSep, '/')
|
||||||
name.add " " & $target & test.options
|
name.add " " & $target & test.options
|
||||||
|
|
||||||
let duration = epochTime() - test.startTime
|
let duration = epochTime() - test.startTime
|
||||||
|
let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout
|
||||||
|
else: successOrig
|
||||||
|
|
||||||
let durationStr = duration.formatFloat(ffDecimal, precision = 8).align(11)
|
let durationStr = duration.formatFloat(ffDecimal, precision = 8).align(11)
|
||||||
if backendLogging:
|
if backendLogging:
|
||||||
backend.writeTestResult(name = name,
|
backend.writeTestResult(name = name,
|
||||||
|
|
|
||||||
7
testament/tests/shouldfail/ttimeout.nim
Normal file
7
testament/tests/shouldfail/ttimeout.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
discard """
|
||||||
|
timeout: "0.1"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
os.sleep(1000)
|
||||||
|
|
@ -27,5 +27,7 @@ FAIL: tests/shouldfail/toutputsub.nim C
|
||||||
Failure: reOutputsDiffer
|
Failure: reOutputsDiffer
|
||||||
FAIL: tests/shouldfail/tsortoutput.nim C
|
FAIL: tests/shouldfail/tsortoutput.nim C
|
||||||
Failure: reOutputsDiffer
|
Failure: reOutputsDiffer
|
||||||
|
FAIL: tests/shouldfail/ttimeout.nim C
|
||||||
|
Failure: reTimeout
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
31
tests/vm/tslow_tables.nim
Normal file
31
tests/vm/tslow_tables.nim
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
discard """
|
||||||
|
timeout: "4"
|
||||||
|
action: "compile"
|
||||||
|
nimout: '''create
|
||||||
|
search
|
||||||
|
done'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #12195
|
||||||
|
|
||||||
|
import tables
|
||||||
|
|
||||||
|
type Flop = object
|
||||||
|
a: int
|
||||||
|
#array[128, int] # <-- compile time is proportional to array size
|
||||||
|
|
||||||
|
proc hop(): bool =
|
||||||
|
var v: Table[int, Flop]
|
||||||
|
|
||||||
|
echo "create"
|
||||||
|
for i in 1..1000:
|
||||||
|
v.add i, Flop()
|
||||||
|
|
||||||
|
echo "search"
|
||||||
|
for i in 1..1000:
|
||||||
|
discard contains(v, i)
|
||||||
|
|
||||||
|
echo "done"
|
||||||
|
|
||||||
|
const r = hop()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue