trunner was not actually being tested in non-CTFFI mode; minor testament cleanups (#14377)
* use check * trunner now works with cpp * cleanup: move compiler/unittest_light => stdtest/unittest_light * fix tests/readme.md * remove deadcode references to rodfiles * fix for windows
This commit is contained in:
parent
27741d6a5c
commit
e909486e5c
14 changed files with 30 additions and 34 deletions
|
|
@ -32,7 +32,6 @@ const
|
|||
"nimble-packages-1",
|
||||
"nimble-packages-2",
|
||||
"niminaction",
|
||||
"rodfiles",
|
||||
"threads",
|
||||
"untestable",
|
||||
"stdlib",
|
||||
|
|
@ -671,10 +670,6 @@ proc processCategory(r: var TResults, cat: Category,
|
|||
options, testsDir: string,
|
||||
runJoinableTests: bool) =
|
||||
case cat.string.normalize
|
||||
of "rodfiles":
|
||||
when false:
|
||||
compileRodFiles(r, cat, options)
|
||||
runRodFiles(r, cat, options)
|
||||
of "ic":
|
||||
when false:
|
||||
icTests(r, testsDir, cat, options)
|
||||
|
|
|
|||
38
testament/lib/stdtest/unittest_light.nim
Normal file
38
testament/lib/stdtest/unittest_light.nim
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# note: consider merging tests/assert/testhelper.nim here.
|
||||
|
||||
proc mismatch*[T](lhs: T, rhs: T): string =
|
||||
## Simplified version of `unittest.require` that satisfies a common use case,
|
||||
## while avoiding pulling too many dependencies. On failure, diagnostic
|
||||
## information is provided that in particular makes it easy to spot
|
||||
## whitespace mismatches and where the mismatch is.
|
||||
proc replaceInvisible(s: string): string =
|
||||
for a in s:
|
||||
case a
|
||||
of '\n': result.add "\\n\n"
|
||||
else: result.add a
|
||||
|
||||
proc quoted(s: string): string = result.addQuoted s
|
||||
|
||||
result.add "\n"
|
||||
result.add "lhs:{" & replaceInvisible(
|
||||
$lhs) & "}\nrhs:{" & replaceInvisible($rhs) & "}\n"
|
||||
when compiles(lhs.len):
|
||||
if lhs.len != rhs.len:
|
||||
result.add "lhs.len: " & $lhs.len & " rhs.len: " & $rhs.len & "\n"
|
||||
when compiles(lhs[0]):
|
||||
var i = 0
|
||||
while i < lhs.len and i < rhs.len:
|
||||
if lhs[i] != rhs[i]: break
|
||||
i.inc
|
||||
result.add "first mismatch index: " & $i & "\n"
|
||||
if i < lhs.len and i < rhs.len:
|
||||
result.add "lhs[i]: {" & quoted($lhs[i]) & "}\nrhs[i]: {" & quoted(
|
||||
$rhs[i]) & "}\n"
|
||||
result.add "lhs[0..<i]:{" & replaceInvisible($lhs[
|
||||
0..<i]) & "}"
|
||||
|
||||
proc assertEquals*[T](lhs: T, rhs: T) =
|
||||
when false: # can be useful for debugging to see all that's fed to this.
|
||||
echo "----" & $lhs
|
||||
if lhs!=rhs:
|
||||
doAssert false, mismatch(lhs, rhs)
|
||||
Loading…
Add table
Add a link
Reference in a new issue