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

This commit is contained in:
Araq
2014-03-04 16:41:37 +01:00
4 changed files with 90 additions and 2 deletions

View File

@@ -1543,7 +1543,7 @@ proc dirRaw(p: var TRstParser): PRstNode =
elif cmpIgnoreCase(result.sons[0].sons[0].text, "latex") == 0:
dirRawAux(p, result, rnRawLatex, parseLiteralBlock)
else:
rstMessage(p, meInvalidDirective, result.sons[0].text)
rstMessage(p, meInvalidDirective, result.sons[0].sons[0].text)
else:
dirRawAux(p, result, rnRaw, parseSectionWrapper)

View File

@@ -2266,6 +2266,7 @@ proc gmtime_r*(a1: var TTime, a2: var Ttm): ptr Ttm {.importc, header: "<time.h>
proc localtime*(a1: var TTime): ptr Ttm {.importc, header: "<time.h>".}
proc localtime_r*(a1: var TTime, a2: var Ttm): ptr Ttm {.importc, header: "<time.h>".}
proc mktime*(a1: var Ttm): TTime {.importc, header: "<time.h>".}
proc timegm*(a1: var Ttm): TTime {.importc, header: "<time.h>".}
proc nanosleep*(a1, a2: var Ttimespec): cint {.importc, header: "<time.h>".}
proc strftime*(a1: cstring, a2: int, a3: cstring,
a4: var Ttm): int {.importc, header: "<time.h>".}

View File

@@ -222,9 +222,88 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
else:
testNoSpec r, makeTest(test, options, cat, actionCompile)
# ----------------------------- babel ----------------------------------------
type PackageFilter = enum
pfCoreOnly
pfExtraOnly
pfAll
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].string
iterator listPackages(filter: PackageFilter): 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)
case filter:
of pfCoreOnly:
if isCorePackage:
yield (name, url)
of pfExtraOnly:
if not isCorePackage:
yield (name, url)
of pfAll:
yield (name, url)
proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
if babelExe == "":
echo("[Warning] - Cannot run babel tests: Babel binary not found.")
return
if execCmd("$# update" % babelExe) == quitFailure:
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
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-core"]
proc `&.?`(a, b: string): string =
# candidate for the stdlib?
@@ -264,6 +343,12 @@ 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-core":
testBabelPackages(r, cat, pfCoreOnly)
of "babel-extra":
testBabelPackages(r, cat, pfExtraOnly)
of "babel-all":
testBabelPackages(r, cat, pfAll)
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