Fix tester on Windows.
This commit is contained in:
parent
4a56ac60d9
commit
08c8ef94ec
1 changed files with 6 additions and 35 deletions
|
|
@ -15,35 +15,6 @@ template cd*(dir: string, body: stmt) =
|
||||||
body
|
body
|
||||||
setCurrentDir(lastDir)
|
setCurrentDir(lastDir)
|
||||||
|
|
||||||
proc execCmdEx2*(command: string, options: set[ProcessOption] = {
|
|
||||||
poUsePath}): tuple[
|
|
||||||
output: TaintedString,
|
|
||||||
error: TaintedString,
|
|
||||||
exitCode: int] {.tags: [ExecIOEffect, ReadIOEffect], gcsafe.} =
|
|
||||||
## A slightly altered version of osproc.execCmdEx
|
|
||||||
## Runs the `command` and returns the standard output, error output, and
|
|
||||||
## exit code.
|
|
||||||
var p = startProcess(command = command, options = options + {poEvalCommand})
|
|
||||||
var outp = outputStream(p)
|
|
||||||
var errp = errorStream(p)
|
|
||||||
result = (TaintedString"", TaintedString"", -1)
|
|
||||||
var outLine = newStringOfCap(120).TaintedString
|
|
||||||
var errLine = newStringOfCap(120).TaintedString
|
|
||||||
while true:
|
|
||||||
var checkForExit = true
|
|
||||||
if outp.readLine(outLine):
|
|
||||||
result[0].string.add(outLine.string)
|
|
||||||
result[0].string.add("\n")
|
|
||||||
checkForExit = false
|
|
||||||
if errp.readLine(errLine):
|
|
||||||
result[1].string.add(errLine.string)
|
|
||||||
result[1].string.add("\n")
|
|
||||||
checkForExit = false
|
|
||||||
if checkForExit:
|
|
||||||
result[2] = peekExitCode(p)
|
|
||||||
if result[2] != -1: break
|
|
||||||
close(p)
|
|
||||||
|
|
||||||
proc processOutput(output: string): seq[string] =
|
proc processOutput(output: string): seq[string] =
|
||||||
output.strip.splitLines().filter((x: string) => (x.len > 0))
|
output.strip.splitLines().filter((x: string) => (x.len > 0))
|
||||||
|
|
||||||
|
|
@ -53,11 +24,11 @@ test "can install packagebin2":
|
||||||
QuitSuccess
|
QuitSuccess
|
||||||
|
|
||||||
test "can reject same version dependencies":
|
test "can reject same version dependencies":
|
||||||
let (outp, errp, exitCode) = execCmdEx2(path &
|
let (outp, exitCode) = execCmdEx(path &
|
||||||
" install -y https://github.com/nimble-test/packagebin.git")
|
" install -y https://github.com/nimble-test/packagebin.git")
|
||||||
# We look at the error output here to avoid out-of-order problems caused by
|
# We look at the error output here to avoid out-of-order problems caused by
|
||||||
# stderr output being generated and flushed without first flushing stdout
|
# stderr output being generated and flushed without first flushing stdout
|
||||||
let ls = errp.strip.splitLines()
|
let ls = outp.strip.splitLines()
|
||||||
check exitCode != QuitSuccess
|
check exitCode != QuitSuccess
|
||||||
check ls[ls.len-1] == "Error: unhandled exception: Cannot satisfy the " &
|
check ls[ls.len-1] == "Error: unhandled exception: Cannot satisfy the " &
|
||||||
"dependency on PackageA 0.2.0 and PackageA 0.5.0 [NimbleError]"
|
"dependency on PackageA 0.2.0 and PackageA 0.5.0 [NimbleError]"
|
||||||
|
|
@ -79,9 +50,9 @@ test "issue #27":
|
||||||
|
|
||||||
test "can uninstall":
|
test "can uninstall":
|
||||||
block:
|
block:
|
||||||
let (outp, errp, exitCode) = execCmdEx2(path & " uninstall -y issue27b")
|
let (outp, exitCode) = execCmdEx(path & " uninstall -y issue27b")
|
||||||
# let ls = outp.processOutput()
|
# let ls = outp.processOutput()
|
||||||
let ls = errp.strip.splitLines()
|
let ls = outp.strip.splitLines()
|
||||||
check exitCode != QuitSuccess
|
check exitCode != QuitSuccess
|
||||||
check ls[ls.len-1] == " Cannot uninstall issue27b (0.1.0) because " &
|
check ls[ls.len-1] == " Cannot uninstall issue27b (0.1.0) because " &
|
||||||
"issue27a (0.1.0) depends on it [NimbleError]"
|
"issue27a (0.1.0) depends on it [NimbleError]"
|
||||||
|
|
@ -92,9 +63,9 @@ test "can uninstall":
|
||||||
# Remove Package*
|
# Remove Package*
|
||||||
check execCmdEx(path & " uninstall -y PackageA@0.5").exitCode == QuitSuccess
|
check execCmdEx(path & " uninstall -y PackageA@0.5").exitCode == QuitSuccess
|
||||||
|
|
||||||
let (outp, errp, exitCode) = execCmdEx2(path & " uninstall -y PackageA")
|
let (outp, exitCode) = execCmdEx(path & " uninstall -y PackageA")
|
||||||
check exitCode != QuitSuccess
|
check exitCode != QuitSuccess
|
||||||
let ls = errp.processOutput()
|
let ls = outp.processOutput()
|
||||||
check ls[ls.len-2].startsWith(" Cannot uninstall PackageA ")
|
check ls[ls.len-2].startsWith(" Cannot uninstall PackageA ")
|
||||||
check ls[ls.len-1].startsWith(" Cannot uninstall PackageA ")
|
check ls[ls.len-1].startsWith(" Cannot uninstall PackageA ")
|
||||||
check execCmdEx(path & " uninstall -y PackageBin2").exitCode == QuitSuccess
|
check execCmdEx(path & " uninstall -y PackageBin2").exitCode == QuitSuccess
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue