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:
Timothee Cour
2021-05-08 08:13:47 -07:00
committed by GitHub
parent eba1c3fd24
commit 4e0f38fbb1
21 changed files with 64 additions and 39 deletions

View File

@@ -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

View File

@@ -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}:

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
ccodecheck: "baz"
"""

View File

@@ -1,6 +1,5 @@
discard """
errormsg: "undeclared identifier: 'undeclared'"
targets: "c"
line: 9
column: 7
"""

View File

@@ -1,6 +1,5 @@
discard """
errormsg: "wrong error message"
targets: "c"
line: 9
column: 6
"""

View File

@@ -1,4 +1,3 @@
discard """
targets: "c"
exitcode: 1
"""

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
errormsg: "undeclared identifier: 'undefined'"
file: "notthisfile.nim"
"""

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
errormsg: "undeclared identifier: 'undeclared'"
line: 10
column: 6

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
maxcodesize: 1
"""

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
nimout: "Hello World!"
action: compile
"""

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
nimout: '''
msg1
msg2

View File

@@ -1,5 +1,4 @@
discard """
targets: "c"
output: '''
done
'''

View File

@@ -1,6 +1,5 @@
discard """
outputsub: "something else"
targets: "c"
"""
echo "Hello World!"

View File

@@ -1,6 +1,5 @@
discard """
action: "reject"
targets: "c"
"""
# Because we set action="reject", we expect this line not to compile. But the

View File

@@ -1,6 +1,5 @@
discard """
sortoutput: true
targets: "c"
output: '''
2
1

View File

@@ -1,6 +1,5 @@
discard """
timeout: "0.1"
targets: "c"
"""
import os

View File

@@ -1,6 +1,5 @@
discard """
valgrind: true
targets: "c"
cmd: "nim $target --gc:arc -d:useMalloc $options $file"
"""