Testament print failed command (#11219)
This commit is contained in:
parent
22881a3543
commit
3ef727adfe
2 changed files with 23 additions and 11 deletions
|
|
@ -515,21 +515,24 @@ proc testNimblePackages(r: var TResults, cat: Category) =
|
||||||
let buildPath = packagesDir / name
|
let buildPath = packagesDir / name
|
||||||
if not existsDir(buildPath):
|
if not existsDir(buildPath):
|
||||||
if hasDep:
|
if hasDep:
|
||||||
let (nimbleOutput, nimbleStatus) = execCmdEx2("nimble", ["install", "-y", name])
|
let (nimbleCmdLine, nimbleOutput, nimbleStatus) = execCmdEx2("nimble", ["install", "-y", name])
|
||||||
if nimbleStatus != QuitSuccess:
|
if nimbleStatus != QuitSuccess:
|
||||||
r.addResult(test, targetC, "", "'nimble install' failed\n" & nimbleOutput, reInstallFailed)
|
let message = "nimble install failed:\n$ " & nimbleCmdLine & "\n" & nimbleOutput
|
||||||
|
r.addResult(test, targetC, "", message, reInstallFailed)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let (installOutput, installStatus) = execCmdEx2("git", ["clone", url, buildPath])
|
let (installCmdLine, installOutput, installStatus) = execCmdEx2("git", ["clone", url, buildPath])
|
||||||
if installStatus != QuitSuccess:
|
if installStatus != QuitSuccess:
|
||||||
r.addResult(test, targetC, "", "'git clone' failed\n" & installOutput, reInstallFailed)
|
let message = "git clone failed:\n$ " & installCmdLine & "\n" & installOutput
|
||||||
|
r.addResult(test, targetC, "", message, reInstallFailed)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let cmdArgs = parseCmdLine(cmd)
|
let cmdArgs = parseCmdLine(cmd)
|
||||||
|
|
||||||
let (buildOutput, buildStatus) = execCmdEx2(cmdArgs[0], cmdArgs[1..^1], workingDir=buildPath)
|
let (buildCmdLine, buildOutput, buildStatus) = execCmdEx2(cmdArgs[0], cmdArgs[1..^1], workingDir=buildPath)
|
||||||
if buildStatus != QuitSuccess:
|
if buildStatus != QuitSuccess:
|
||||||
r.addResult(test, targetC, "", "package test failed\n" & buildOutput, reBuildFailed)
|
let message = "package test failed\n$ " & buildCmdLine & "\n" & buildOutput
|
||||||
|
r.addResult(test, targetC, "", message, reBuildFailed)
|
||||||
else:
|
else:
|
||||||
inc r.passed
|
inc r.passed
|
||||||
r.addResult(test, targetC, "", "", reSuccess)
|
r.addResult(test, targetC, "", "", reSuccess)
|
||||||
|
|
@ -646,8 +649,9 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
|
|
||||||
let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "megatest.nim"]
|
let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "megatest.nim"]
|
||||||
proc onStdout(line: string) = echo line
|
proc onStdout(line: string) = echo line
|
||||||
var (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
|
||||||
echo buf.string
|
echo buf.string
|
||||||
quit("megatest compilation failed")
|
quit("megatest compilation failed")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,16 @@ proc getFileDir(filename: string): string =
|
||||||
result = getCurrentDir() / result
|
result = getCurrentDir() / result
|
||||||
|
|
||||||
proc execCmdEx2(command: string, args: openarray[string]; workingDir, input: string = ""): tuple[
|
proc execCmdEx2(command: string, args: openarray[string]; workingDir, input: string = ""): tuple[
|
||||||
|
cmdLine: string,
|
||||||
output: TaintedString,
|
output: TaintedString,
|
||||||
exitCode: int] {.tags:
|
exitCode: int] {.tags:
|
||||||
[ExecIOEffect, ReadIOEffect, RootEffect], gcsafe.} =
|
[ExecIOEffect, ReadIOEffect, RootEffect], gcsafe.} =
|
||||||
|
|
||||||
|
result.cmdLine.add quoteShell(command)
|
||||||
|
for arg in args:
|
||||||
|
result.cmdLine.add ' '
|
||||||
|
result.cmdLine.add quoteShell(arg)
|
||||||
|
|
||||||
var p = startProcess(command, workingDir=workingDir, args=args, options={poStdErrToStdOut, poUsePath})
|
var p = startProcess(command, workingDir=workingDir, args=args, options={poStdErrToStdOut, poUsePath})
|
||||||
var outp = outputStream(p)
|
var outp = outputStream(p)
|
||||||
|
|
||||||
|
|
@ -103,7 +110,7 @@ proc execCmdEx2(command: string, args: openarray[string]; workingDir, input: str
|
||||||
instream.write(input)
|
instream.write(input)
|
||||||
close instream
|
close instream
|
||||||
|
|
||||||
result = (TaintedString"", -1)
|
result.exitCode = -1
|
||||||
var line = newStringOfCap(120).TaintedString
|
var line = newStringOfCap(120).TaintedString
|
||||||
while true:
|
while true:
|
||||||
if outp.readLine(line):
|
if outp.readLine(line):
|
||||||
|
|
@ -130,6 +137,7 @@ proc prepareTestArgs(cmdTemplate, filename, options: string,
|
||||||
proc callCompiler(cmdTemplate, filename, options: string,
|
proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
target: TTarget, extraOptions=""): TSpec =
|
target: TTarget, extraOptions=""): TSpec =
|
||||||
let c = prepareTestArgs(cmdTemplate, filename, options, target, extraOptions)
|
let c = prepareTestArgs(cmdTemplate, filename, options, target, extraOptions)
|
||||||
|
result.cmd = quoteShellCommand(c)
|
||||||
var p = startProcess(command=c[0], args=c[1 .. ^1],
|
var p = startProcess(command=c[0], args=c[1 .. ^1],
|
||||||
options={poStdErrToStdOut, poUsePath})
|
options={poStdErrToStdOut, poUsePath})
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
|
|
@ -371,7 +379,7 @@ proc compilerOutputTests(test: TTest, target: TTarget, given: var TSpec,
|
||||||
givenmsg = given.nimout.strip
|
givenmsg = given.nimout.strip
|
||||||
nimoutCheck(test, expectedmsg, given)
|
nimoutCheck(test, expectedmsg, given)
|
||||||
else:
|
else:
|
||||||
givenmsg = given.nimout.strip
|
givenmsg = "$ " & given.cmd & "\n" & given.nimout
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
r.addResult(test, target, expectedmsg, givenmsg, given.err)
|
r.addResult(test, target, expectedmsg, givenmsg, given.err)
|
||||||
|
|
||||||
|
|
@ -426,7 +434,7 @@ 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, target)
|
var given = callCompiler(expected.getCmd, test.name, test.options, target)
|
||||||
if given.err != reSuccess:
|
if given.err != reSuccess:
|
||||||
r.addResult(test, target, "", given.nimout, given.err)
|
r.addResult(test, target, "", "$ " & given.cmd & "\n" & given.nimout, given.err)
|
||||||
continue
|
continue
|
||||||
let isJsTarget = target == targetJS
|
let isJsTarget = target == targetJS
|
||||||
var exeFile = changeFileExt(test.name, if isJsTarget: "js" else: ExeExt)
|
var exeFile = changeFileExt(test.name, if isJsTarget: "js" else: ExeExt)
|
||||||
|
|
@ -447,7 +455,7 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
args = concat(@[exeFile], args)
|
args = concat(@[exeFile], args)
|
||||||
else:
|
else:
|
||||||
exeCmd = exeFile
|
exeCmd = exeFile
|
||||||
var (buf, exitCode) = execCmdEx2(exeCmd, args, input = expected.input)
|
var (cmdLine, buf, exitCode) = execCmdEx2(exeCmd, args, 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue