misc testament cleanups (#14764)

* misc testament cleanups extracted cleanups from #14530

* make sure all CI failures can be searched with `FAIL: ` including megatest failures
This commit is contained in:
Timothee Cour 2020-06-23 01:53:03 -07:00 • committed by GitHub
commit a9eee6db65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 35 deletions

View file

@ -587,13 +587,6 @@ proc quoted(a: string): string =
# todo: consider moving to system.nim # todo: consider moving to system.nim
result.addQuoted(a) result.addQuoted(a)
proc normalizeExe(file: string): string =
# xxx common pattern, should be exposed in std/os, even if simple (error prone)
when defined(posix):
if file.len == 0: ""
elif DirSep in file: file else: "./" & file
else: file
proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
## returns a list of tests that have problems ## returns a list of tests that have problems
var specs: seq[TSpec] = @[] var specs: seq[TSpec] = @[]
@ -618,12 +611,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
return return
var megatest: string var megatest: string
#[ # xxx (minor) put outputExceptedFile, outputGottenFile, megatestFile under here or `buildDir`
TODO(minor):
get from Nim cmd
put outputGotten.txt, outputGotten.txt, megatest.nim there too
delete upon completion, maybe
]#
var outDir = nimcacheDir(testsDir / "megatest", "", targetC) var outDir = nimcacheDir(testsDir / "megatest", "", targetC)
const marker = "megatest:processing: " const marker = "megatest:processing: "
@ -644,15 +632,17 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "") var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
if exitCode != 0: if exitCode != 0:
echo "$ " & cmdLine & "\n" & buf.string echo "$ " & cmdLine & "\n" & buf.string
quit("megatest compilation failed") quit(failString & "megatest compilation failed")
(buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).normalizeExe) (buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).dup normalizeExe)
if exitCode != 0: if exitCode != 0:
echo buf.string echo buf.string
quit("megatest execution failed") quit(failString & "megatest execution failed")
norm buf.string norm buf.string
writeFile("outputGotten.txt", buf.string) const outputExceptedFile = "outputExpected.txt"
const outputGottenFile = "outputGotten.txt"
writeFile(outputGottenFile, buf.string)
var outputExpected = "" var outputExpected = ""
for i, runSpec in specs: for i, runSpec in specs:
outputExpected.add marker & runSpec.file & "\n" outputExpected.add marker & runSpec.file & "\n"
@ -661,14 +651,14 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
norm outputExpected norm outputExpected
if buf.string != outputExpected: if buf.string != outputExpected:
writeFile("outputExpected.txt", outputExpected) writeFile(outputExceptedFile, outputExpected)
discard execShellCmd("diff -uNdr outputExpected.txt outputGotten.txt") discard execShellCmd("diff -uNdr $1 $2" % [outputExceptedFile, outputGottenFile])
echo "output different!" echo failString & "megatest output different!"
# outputGotten.txt, outputExpected.txt not removed on purpose for debugging. # outputGottenFile, outputExceptedFile not removed on purpose for debugging.
quit 1 quit 1
else: else:
echo "output OK" echo "megatest output OK"
removeFile("outputGotten.txt") removeFile(outputGottenFile)
removeFile(megatestFile) removeFile(megatestFile)
#testSpec r, makeTest("megatest", options, cat) #testSpec r, makeTest("megatest", options, cat)

View file

@ -21,6 +21,7 @@ var backendLogging = true
var simulate = false var simulate = false
const const
failString* = "FAIL: " # ensures all failures can be searched with 1 keyword in CI logs
testsDir = "tests" & DirSep testsDir = "tests" & DirSep
resultsFile = "testresults.html" resultsFile = "testresults.html"
#jsonFile = "testresults.json" # not used #jsonFile = "testresults.json" # not used
@ -279,7 +280,7 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
elif success == reJoined: elif success == reJoined:
maybeStyledEcho styleDim, fgYellow, "JOINED: ", styleBright, fgCyan, name maybeStyledEcho styleDim, fgYellow, "JOINED: ", styleBright, fgCyan, name
else: else:
maybeStyledEcho styleBright, fgRed, "FAIL: ", fgCyan, name maybeStyledEcho styleBright, fgRed, failString, fgCyan, name
maybeStyledEcho styleBright, fgCyan, "Test \"", test.name, "\"", " in category \"", test.cat.string, "\"" maybeStyledEcho styleBright, fgCyan, "Test \"", test.name, "\"", " in category \"", test.cat.string, "\""
maybeStyledEcho styleBright, fgRed, "Failure: ", $success maybeStyledEcho styleBright, fgRed, "Failure: ", $success
if success in {reBuildFailed, reNimcCrash, reInstallFailed}: if success in {reBuildFailed, reNimcCrash, reInstallFailed}:
@ -701,7 +702,7 @@ proc main() =
cmds.add(myself & runtype & quoteShell(cat) & rest) cmds.add(myself & runtype & quoteShell(cat) & rest)
proc progressStatus(idx: int) = proc progressStatus(idx: int) =
echo "progress[all]: i: " & $idx & " / " & $cats.len & " cat: " & cats[idx] echo "progress[all]: $1/$2 starting: cat: $3" % [$idx, $cats.len, cats[idx]]
if simulate: if simulate:
skips = loadSkipFrom(skipFrom) skips = loadSkipFrom(skipFrom)

View file

@ -1,10 +1,4 @@
discard """
output: '''uint
1'''
"""
# Tests unsigned literals and implicit conversion between uints and ints # Tests unsigned literals and implicit conversion between uints and ints
# Passes if it compiles
var h8:uint8 = 128 var h8:uint8 = 128
var h16:uint16 = 32768 var h16:uint16 = 32768
@ -53,7 +47,7 @@ block t4176:
proc fun(): uint = cast[uint](-1) proc fun(): uint = cast[uint](-1)
const x0 = fun() const x0 = fun()
echo typeof(x0) doAssert typeof(x0) is uint
discard $x0 discard $x0
@ -62,6 +56,6 @@ discard $x0
const x1 = cast[uint](-1) const x1 = cast[uint](-1)
discard $(x1,) discard $(x1,)
# bug 13698 # bug #13698
let n: csize = 1 let n: csize = 1 # xxx should that be csize_t or is that essential here?
echo n.int32 doAssert $n.int32 == "1"

View file

@ -31,3 +31,5 @@ FAIL: tests/shouldfail/ttimeout.nim C
Failure: reTimeout Failure: reTimeout
''' '''
""" """
# xxx `--nim:../compiler/nim`, doesn't seem correct (and should also honor `testament --nim`)