Merge branch 'devel' of https://github.com/Araq/Nimrod into new_spawn

Conflicts:
	lib/system.nim
This commit is contained in:
Araq 2014-06-26 17:19:28 +02:00
commit 85a1d896c2
40 changed files with 385 additions and 114 deletions

View file

@ -0,0 +1,14 @@
discard """
output: "13{(.{}}{*4&*$**()&*@1235"
"""
type
Test = enum
`1`, `3`, `{`, `(.`, `{}}{`, `*4&*$**()&*@`
let `.}` = 1
let `(}` = 2
let `[` = 3
let `]` = 5
echo `1`, `3`, `{`, `(.`, `{}}{`, `*4&*$**()&*@`, `.}`, `(}`, `[`, `]`

14
tests/notnil/tnotnil4.nim Normal file
View file

@ -0,0 +1,14 @@
discard ""
type
TObj = ref object
proc check(a: TObj not nil) =
echo repr(a)
proc doit() =
var x : array[0..1, TObj]
if x[0] != nil:
check(x[0])
doit()

3
tests/osproc/ta.nim Normal file
View file

@ -0,0 +1,3 @@
import strutils
let x = stdin.readLine()
echo x.parseInt + 5

16
tests/osproc/tstdin.nim Normal file
View file

@ -0,0 +1,16 @@
discard """
file: "tstdin.nim"
output: "10"
"""
import osproc, os, streams
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / "ta.exe")
var p = startProcess("ta.exe", getCurrentDir() / "tests" / "osproc")
p.inputStream.write("5\n")
while true:
let line = p.outputStream.readLine()
if line != "":
echo line
else:
break

View file

@ -86,6 +86,10 @@ proc doProcCommand(session: var TNimrodSession, command: string): string =
proc doCommand(session: var TNimrodSession, command: string) =
if session.mode == CaasRun:
if not session.nim.running:
session.lastOutput = "FAILED TO EXECUTE: " & command & "\n" &
"Exit code " & $session.nim.peekExitCode
return
session.lastOutput = doCaasCommand(session,
command & " " & session.filename)
else:
@ -102,7 +106,7 @@ proc close(session: var TNimrodSession) {.destructor.} =
if session.mode == CaasRun:
session.nim.close
proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
proc doScenario(script: string, output: PStream, mode: TRunMode, verbose: bool): bool =
result = true
var f = open(script)
@ -134,7 +138,7 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
continue
elif line.startsWith(">"):
s.doCommand(line.substr(1).strip)
output.writeln line, "\n", s.lastOutput
output.writeln line, "\n", if verbose: s.lastOutput else: ""
else:
var expectMatch = true
var pattern = s.replaceVars(line)
@ -151,13 +155,14 @@ proc doScenario(script: string, output: PStream, mode: TRunMode): bool =
output.writeln "FAILURE ", line
result = false
iterator caasTestsRunner*(filter = ""): tuple[test, output: string,
status: bool, mode: TRunMode] =
iterator caasTestsRunner*(filter = "", verbose = false): tuple[test,
output: string, status: bool,
mode: TRunMode] =
for scenario in os.walkFiles(TesterDir / "caas/*.txt"):
if filter.len > 0 and find(scenario, filter) == -1: continue
for mode in modes:
var outStream = newStringStream()
let r = doScenario(scenario, outStream, mode)
let r = doScenario(scenario, outStream, mode, verbose)
yield (scenario, outStream.data, r, mode)
when isMainModule:
@ -175,9 +180,12 @@ when isMainModule:
if verbose and len(filter) > 0:
echo "Running only test cases matching filter '$1'" % [filter]
for test, output, result, mode in caasTestsRunner(filter):
for test, output, result, mode in caasTestsRunner(filter, verbose):
if not result or verbose:
echo test, "\n", output, "-> ", $mode, ":", $result, "\n-----"
echo "Mode ", $mode, " (", if result: "succeeded)" else: "failed)"
echo test
echo output
echo "---------\n"
if not result:
failures += 1

View file

@ -282,26 +282,33 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
echo("[Warning] - Cannot run babel tests: Babel update failed.")
return
for name, url in listPackages(filter):
var test = makeTest(name, "", cat)
echo(url)
let
installProcess = startProcess(babelExe, "", ["install", "-y", name])
installStatus = waitForExitEx(installProcess)
installProcess.close
if installStatus != quitSuccess:
r.addResult(test, "", "", reInstallFailed)
continue
let packageFileTest = makeTest("PackageFileParsed", "", cat)
try:
for name, url in listPackages(filter):
var test = makeTest(name, "", cat)
echo(url)
let
installProcess = startProcess(babelExe, "", ["install", "-y", name])
installStatus = waitForExitEx(installProcess)
installProcess.close
if installStatus != quitSuccess:
r.addResult(test, "", "", reInstallFailed)
continue
let
buildPath = getPackageDir(name)[0.. -3]
let
buildProcess = startProcess(babelExe, buildPath, ["build"])
buildStatus = waitForExitEx(buildProcess)
buildProcess.close
if buildStatus != quitSuccess:
r.addResult(test, "", "", reBuildFailed)
r.addResult(test, "", "", reSuccess)
r.addResult(packageFileTest, "", "", reSuccess)
except EJsonParsingError:
echo("[Warning] - Cannot run babel tests: Invalid package file.")
r.addResult(packageFileTest, "", "", reBuildFailed)
let
buildPath = getPackageDir(name)[0.. -3]
let
buildProcess = startProcess(babelExe, buildPath, ["build"])
buildStatus = waitForExitEx(buildProcess)
buildProcess.close
if buildStatus != quitSuccess:
r.addResult(test, "", "", reBuildFailed)
r.addResult(test, "", "", reSuccess)
# ----------------------------------------------------------------------------