make more tests green

This commit is contained in:
Araq
2018-12-10 15:28:46 +01:00
parent 4d616b5dc4
commit 916955dc95
3 changed files with 10 additions and 54 deletions

View File

@@ -246,7 +246,7 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
maybeStyledEcho fgYellow, "Gotten:"
maybeStyledEcho styleBright, given, "\n"
if existsEnv("APPVEYOR"):
if backendLogging and existsEnv("APPVEYOR"):
let (outcome, msg) =
if success == reSuccess:
("Passed", "")
@@ -358,26 +358,21 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
r.addResult(test, targetC, "", expected.parseErrors, reInvalidSpec)
inc(r.total)
return
if expected.err in {reDisabled, reJoined}:
# targetC is a lie, but parameter is required
r.addResult(test, targetC, "", "", expected.err)
inc(r.skipped)
inc(r.total)
return
expected.targets.incl targets
# still no target specified at all
if expected.targets == {}:
if getEnv("NIM_COMPILE_TO_CPP", "false").string == "true":
expected.targets = {targetCpp}
else:
expected.targets = {targetC}
for target in expected.targets:
inc(r.total)
case expected.action
of actionCompile:
var given = callCompiler(expected.getCmd, test.name, test.options, target,
@@ -388,11 +383,9 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
# nested conditionals - the empty rows in between to clarify the "danger"
var given = callCompiler(expected.getCmd, test.name, test.options,
target)
if given.err != reSuccess:
r.addResult(test, target, "", given.msg, given.err)
continue
let isJsTarget = target == targetJS
var exeFile: string
if isJsTarget:
@@ -410,8 +403,6 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
r.addResult(test, target, expected.output, "nodejs binary not in PATH",
reExeNotFound)
continue
var exeCmd: string
var args: seq[string]
if isJsTarget:
@@ -419,13 +410,10 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
args.add exeFile
else:
exeCmd = exeFile
var (buf, exitCode) = execCmdEx2(exeCmd, args, options = {poStdErrToStdOut}, input = expected.input)
# Treat all failure codes from nodejs as 1. Older versions of nodejs used
# to return other codes, but for us it is sufficient to know that it's not 0.
if exitCode != 0: exitCode = 1
let bufB =
if expected.sortoutput:
var x = splitLines(strip(buf.string))
@@ -433,22 +421,18 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
join(x, "\n")
else:
strip(buf.string)
if exitCode != expected.exitCode:
r.addResult(test, target, "exitcode: " & $expected.exitCode,
"exitcode: " & $exitCode & "\n\nOutput:\n" &
bufB, reExitCodesDiffer)
continue
if (expected.outputCheck == ocEqual and expected.output != bufB) or
(expected.outputCheck == ocSubstr and expected.output notin bufB):
given.err = reOutputsDiffer
r.addResult(test, target, expected.output, bufB, reOutputsDiffer)
continue
compilerOutputTests(test, target, given, expected, r)
continue
of actionReject:
var given = callCompiler(expected.getCmd, test.name, test.options,
target)
@@ -523,7 +507,7 @@ proc main() =
targetsStr = p.val.string
targets = parseTargets(targetsStr)
of "nim":
compilerPrefix = p.val.string
compilerPrefix = addFileExt(p.val.string, ExeExt)
of "directory":
setCurrentDir(p.val.string)
of "colors":

View File

@@ -1,28 +0,0 @@
discard """
output: "helloworld99110223"
"""
# Same test, but check module boundaries
import tbintree
var
root: PBinaryTree[string]
x = newNode("hello")
add(root, x)
add(root, "world")
if find(root, "world"):
for str in items(root):
stdout.write(str)
else:
stdout.writeLine("BUG")
var
r2: PBinaryTree[int]
add(r2, newNode(110))
add(r2, 223)
add(r2, 99)
for y in items(r2):
stdout.write(y)
#OUT helloworld99110223
stdout.write "\n"

View File

@@ -1,5 +1,9 @@
discard """
output: "helloworld99110223"
output: '''hello
world
99
110
223'''
"""
type
TBinaryTree[T] = object # TBinaryTree is a generic type with
@@ -89,9 +93,9 @@ when true:
add(root, "world")
if find(root, "world"):
for str in items(root):
stdout.write(str)
echo(str)
else:
stdout.writeLine("BUG")
echo("BUG")
var
r2: PBinaryTree[int]
@@ -99,8 +103,4 @@ when true:
add(r2, 223)
add(r2, 99)
for y in items(r2):
stdout.write(y)
stdout.write "\n"
#OUT helloworld99110223
echo(y)