make more tests green
This commit is contained in:
parent
4d616b5dc4
commit
916955dc95
3 changed files with 10 additions and 54 deletions
|
|
@ -246,7 +246,7 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||||
maybeStyledEcho fgYellow, "Gotten:"
|
maybeStyledEcho fgYellow, "Gotten:"
|
||||||
maybeStyledEcho styleBright, given, "\n"
|
maybeStyledEcho styleBright, given, "\n"
|
||||||
|
|
||||||
if existsEnv("APPVEYOR"):
|
if backendLogging and existsEnv("APPVEYOR"):
|
||||||
let (outcome, msg) =
|
let (outcome, msg) =
|
||||||
if success == reSuccess:
|
if success == reSuccess:
|
||||||
("Passed", "")
|
("Passed", "")
|
||||||
|
|
@ -358,26 +358,21 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
r.addResult(test, targetC, "", expected.parseErrors, reInvalidSpec)
|
r.addResult(test, targetC, "", expected.parseErrors, reInvalidSpec)
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
return
|
return
|
||||||
|
|
||||||
if expected.err in {reDisabled, reJoined}:
|
if expected.err in {reDisabled, reJoined}:
|
||||||
# targetC is a lie, but parameter is required
|
# targetC is a lie, but parameter is required
|
||||||
r.addResult(test, targetC, "", "", expected.err)
|
r.addResult(test, targetC, "", "", expected.err)
|
||||||
inc(r.skipped)
|
inc(r.skipped)
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
return
|
return
|
||||||
|
|
||||||
expected.targets.incl targets
|
expected.targets.incl targets
|
||||||
|
|
||||||
# still no target specified at all
|
# still no target specified at all
|
||||||
if expected.targets == {}:
|
if expected.targets == {}:
|
||||||
if getEnv("NIM_COMPILE_TO_CPP", "false").string == "true":
|
if getEnv("NIM_COMPILE_TO_CPP", "false").string == "true":
|
||||||
expected.targets = {targetCpp}
|
expected.targets = {targetCpp}
|
||||||
else:
|
else:
|
||||||
expected.targets = {targetC}
|
expected.targets = {targetC}
|
||||||
|
|
||||||
for target in expected.targets:
|
for target in expected.targets:
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
|
|
||||||
case expected.action
|
case expected.action
|
||||||
of actionCompile:
|
of actionCompile:
|
||||||
var given = callCompiler(expected.getCmd, test.name, test.options, target,
|
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"
|
# nested conditionals - the empty rows in between to clarify the "danger"
|
||||||
var given = callCompiler(expected.getCmd, test.name, test.options,
|
var given = callCompiler(expected.getCmd, test.name, test.options,
|
||||||
target)
|
target)
|
||||||
|
|
||||||
if given.err != reSuccess:
|
if given.err != reSuccess:
|
||||||
r.addResult(test, target, "", given.msg, given.err)
|
r.addResult(test, target, "", given.msg, given.err)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let isJsTarget = target == targetJS
|
let isJsTarget = target == targetJS
|
||||||
var exeFile: string
|
var exeFile: string
|
||||||
if isJsTarget:
|
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",
|
r.addResult(test, target, expected.output, "nodejs binary not in PATH",
|
||||||
reExeNotFound)
|
reExeNotFound)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
var exeCmd: string
|
var exeCmd: string
|
||||||
var args: seq[string]
|
var args: seq[string]
|
||||||
if isJsTarget:
|
if isJsTarget:
|
||||||
|
|
@ -419,13 +410,10 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
args.add exeFile
|
args.add exeFile
|
||||||
else:
|
else:
|
||||||
exeCmd = exeFile
|
exeCmd = exeFile
|
||||||
|
|
||||||
var (buf, exitCode) = execCmdEx2(exeCmd, args, options = {poStdErrToStdOut}, input = expected.input)
|
var (buf, exitCode) = execCmdEx2(exeCmd, args, options = {poStdErrToStdOut}, input = expected.input)
|
||||||
|
|
||||||
# Treat all failure codes from nodejs as 1. Older versions of nodejs used
|
# 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.
|
# to return other codes, but for us it is sufficient to know that it's not 0.
|
||||||
if exitCode != 0: exitCode = 1
|
if exitCode != 0: exitCode = 1
|
||||||
|
|
||||||
let bufB =
|
let bufB =
|
||||||
if expected.sortoutput:
|
if expected.sortoutput:
|
||||||
var x = splitLines(strip(buf.string))
|
var x = splitLines(strip(buf.string))
|
||||||
|
|
@ -433,22 +421,18 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
join(x, "\n")
|
join(x, "\n")
|
||||||
else:
|
else:
|
||||||
strip(buf.string)
|
strip(buf.string)
|
||||||
|
|
||||||
if exitCode != expected.exitCode:
|
if exitCode != expected.exitCode:
|
||||||
r.addResult(test, target, "exitcode: " & $expected.exitCode,
|
r.addResult(test, target, "exitcode: " & $expected.exitCode,
|
||||||
"exitcode: " & $exitCode & "\n\nOutput:\n" &
|
"exitcode: " & $exitCode & "\n\nOutput:\n" &
|
||||||
bufB, reExitCodesDiffer)
|
bufB, reExitCodesDiffer)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (expected.outputCheck == ocEqual and expected.output != bufB) or
|
if (expected.outputCheck == ocEqual and expected.output != bufB) or
|
||||||
(expected.outputCheck == ocSubstr and expected.output notin bufB):
|
(expected.outputCheck == ocSubstr and expected.output notin bufB):
|
||||||
given.err = reOutputsDiffer
|
given.err = reOutputsDiffer
|
||||||
r.addResult(test, target, expected.output, bufB, reOutputsDiffer)
|
r.addResult(test, target, expected.output, bufB, reOutputsDiffer)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
compilerOutputTests(test, target, given, expected, r)
|
compilerOutputTests(test, target, given, expected, r)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
of actionReject:
|
of actionReject:
|
||||||
var given = callCompiler(expected.getCmd, test.name, test.options,
|
var given = callCompiler(expected.getCmd, test.name, test.options,
|
||||||
target)
|
target)
|
||||||
|
|
@ -523,7 +507,7 @@ proc main() =
|
||||||
targetsStr = p.val.string
|
targetsStr = p.val.string
|
||||||
targets = parseTargets(targetsStr)
|
targets = parseTargets(targetsStr)
|
||||||
of "nim":
|
of "nim":
|
||||||
compilerPrefix = p.val.string
|
compilerPrefix = addFileExt(p.val.string, ExeExt)
|
||||||
of "directory":
|
of "directory":
|
||||||
setCurrentDir(p.val.string)
|
setCurrentDir(p.val.string)
|
||||||
of "colors":
|
of "colors":
|
||||||
|
|
|
||||||
|
|
@ -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"
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
output: "helloworld99110223"
|
output: '''hello
|
||||||
|
world
|
||||||
|
99
|
||||||
|
110
|
||||||
|
223'''
|
||||||
"""
|
"""
|
||||||
type
|
type
|
||||||
TBinaryTree[T] = object # TBinaryTree is a generic type with
|
TBinaryTree[T] = object # TBinaryTree is a generic type with
|
||||||
|
|
@ -89,9 +93,9 @@ when true:
|
||||||
add(root, "world")
|
add(root, "world")
|
||||||
if find(root, "world"):
|
if find(root, "world"):
|
||||||
for str in items(root):
|
for str in items(root):
|
||||||
stdout.write(str)
|
echo(str)
|
||||||
else:
|
else:
|
||||||
stdout.writeLine("BUG")
|
echo("BUG")
|
||||||
|
|
||||||
var
|
var
|
||||||
r2: PBinaryTree[int]
|
r2: PBinaryTree[int]
|
||||||
|
|
@ -99,8 +103,4 @@ when true:
|
||||||
add(r2, 223)
|
add(r2, 223)
|
||||||
add(r2, 99)
|
add(r2, 99)
|
||||||
for y in items(r2):
|
for y in items(r2):
|
||||||
stdout.write(y)
|
echo(y)
|
||||||
|
|
||||||
stdout.write "\n"
|
|
||||||
|
|
||||||
#OUT helloworld99110223
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue