Integrated 'babel' with testament

This commit is contained in:
Clay Sweetser
2014-03-01 17:41:50 -05:00
parent 0d263f155b
commit 3249f16d85
2 changed files with 71 additions and 1 deletions

View File

@@ -222,9 +222,75 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
else:
testNoSpec r, makeTest(test, options, cat, actionCompile)
# ----------------------------- babel ----------------------------------------
let
babelExe = findExe("babel")
babelDir = getHomeDir() / ".babel"
packageDir = babelDir / "pkgs"
packageIndex = babelDir / "packages.json"
proc waitForExitEx(p: PProcess): int =
var outp: PStream = outputStream(p)
var line = newStringOfCap(120).TaintedString
while true:
if outp.readLine(line):
discard
else:
result = peekExitCode(p)
if result != -1: break
close(p)
proc getPackageDir(package: string): string =
## TODO - Replace this with dom's version comparison magic.
var commandOutput = execCmdEx("babel path $#" % package)
if commandOutput.exitCode != quitSuccess:
return ""
else:
result = commandOutput[0]
iterator listPackages(listAll = false): tuple[name, url: string] =
let packageList = parseFile(packageIndex)
for package in packageList.items():
let
name = package["name"].str
url = package["url"].str
isCorePackage = "nimrod-code" in normalize(url)
if isCorePackage or listAll:
yield (name, url)
proc testBabelPackages(r: var TResults, options: string, cat: Category) =
if babelExe == "":
quit("Cannot run babel tests: Babel binary not found.", quitFailure)
if execCmd("$# update" % babelExe) == quitFailure:
quit("Cannot run babel tests: Babel update failed.")
for name, url in listPackages():
var test = makeTest(name, options, 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)
# ----------------------------------------------------------------------------
const AdditionalCategories = ["debugger", "tools", "examples", "stdlib"]
const AdditionalCategories = ["debugger", "tools", "examples", "stdlib", "babel"]
proc `&.?`(a, b: string): string =
# candidate for the stdlib?
@@ -264,6 +330,8 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
compileExample(r, "examples/*.nim", options, cat)
compileExample(r, "examples/gtk/*.nim", options, cat)
compileExample(r, "examples/talk/*.nim", options, cat)
of "babel":
testBabelPackages(r, options, cat)
else:
for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
testSpec r, makeTest(name, options, cat)

View File

@@ -28,6 +28,8 @@ type
reCodegenFailure,
reCodeNotFound,
reExeNotFound,
reInstallFailed # package installation failed
reBuildFailed # package building failed
reIgnored, # test is ignored
reSuccess # test was successful
TTarget* = enum