mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
testament :show duration also for failed tests; improve tshould_not_work; mitigate #17946 tchannels timeouts (#17947)
* refs #17946; refactor testament test summary, show test duration for failures; increase timeout tchannels * revert workarounds from https://github.com/nim-lang/Nim/pull/16698 and add allowPrefixMatch optional param to greedyOrderedSubsetLines * add test * workaround for yet another testament bug
This commit is contained in:
@@ -29,11 +29,17 @@ template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
|
||||
when not defined(js):
|
||||
import std/strutils
|
||||
|
||||
proc greedyOrderedSubsetLines*(lhs, rhs: string): bool =
|
||||
proc greedyOrderedSubsetLines*(lhs, rhs: string, allowPrefixMatch = false): bool =
|
||||
## Returns true if each stripped line in `lhs` appears in rhs, using a greedy matching.
|
||||
# xxx improve error reporting by showing the last matched pair
|
||||
iterator splitLinesClosure(): string {.closure.} =
|
||||
for line in splitLines(rhs.strip):
|
||||
yield line
|
||||
template isMatch(lhsi, rhsi): bool =
|
||||
if allowPrefixMatch:
|
||||
startsWith(rhsi, lhsi):
|
||||
else:
|
||||
lhsi == rhsi
|
||||
|
||||
var rhsIter = splitLinesClosure
|
||||
var currentLine = strip(rhsIter())
|
||||
@@ -41,7 +47,7 @@ when not defined(js):
|
||||
for line in lhs.strip.splitLines:
|
||||
let line = line.strip
|
||||
if line.len != 0:
|
||||
while line != currentLine:
|
||||
while not isMatch(line, currentLine):
|
||||
currentLine = strip(rhsIter())
|
||||
if rhsIter.finished:
|
||||
return false
|
||||
|
||||
@@ -288,16 +288,18 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||
expected = expected,
|
||||
given = given)
|
||||
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
|
||||
template dispNonSkipped(color, outcome) =
|
||||
maybeStyledEcho color, outcome, fgCyan, test.debugInfo, alignLeft(name, 60), fgBlue, " (", durationStr, " sec)"
|
||||
template disp(msg) =
|
||||
maybeStyledEcho styleDim, fgYellow, msg & ' ', styleBright, fgCyan, name
|
||||
if success == reSuccess:
|
||||
maybeStyledEcho fgGreen, "PASS: ", fgCyan, test.debugInfo, alignLeft(name, 60), fgBlue, " (", durationStr, " sec)"
|
||||
dispNonSkipped(fgGreen, "PASS: ")
|
||||
elif success == reDisabled:
|
||||
if test.spec.inCurrentBatch: disp("SKIP:")
|
||||
else: disp("NOTINBATCH:")
|
||||
elif success == reJoined: disp("JOINED:")
|
||||
else:
|
||||
maybeStyledEcho styleBright, fgRed, failString, fgCyan, name
|
||||
dispNonSkipped(fgRed, failString)
|
||||
maybeStyledEcho styleBright, fgCyan, "Test \"", test.name, "\"", " in category \"", test.cat.string, "\""
|
||||
maybeStyledEcho styleBright, fgRed, "Failure: ", $success
|
||||
if success in {reBuildFailed, reNimcCrash, reInstallFailed}:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
ccodecheck: "baz"
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
errormsg: "undeclared identifier: 'undeclared'"
|
||||
targets: "c"
|
||||
line: 9
|
||||
column: 7
|
||||
"""
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
errormsg: "wrong error message"
|
||||
targets: "c"
|
||||
line: 9
|
||||
column: 6
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
exitcode: 1
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
errormsg: "undeclared identifier: 'undefined'"
|
||||
file: "notthisfile.nim"
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
errormsg: "undeclared identifier: 'undeclared'"
|
||||
line: 10
|
||||
column: 6
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
maxcodesize: 1
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
nimout: "Hello World!"
|
||||
action: compile
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
nimout: '''
|
||||
msg1
|
||||
msg2
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
output: '''
|
||||
done
|
||||
'''
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
outputsub: "something else"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
echo "Hello World!"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
action: "reject"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
# Because we set action="reject", we expect this line not to compile. But the
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
sortoutput: true
|
||||
targets: "c"
|
||||
output: '''
|
||||
2
|
||||
1
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
timeout: "0.1"
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
discard """
|
||||
valgrind: true
|
||||
targets: "c"
|
||||
cmd: "nim $target --gc:arc -d:useMalloc $options $file"
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user