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