From c2b50c0e38d758f86ae8909649da545235a6b7c6 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sat, 15 Feb 2014 17:50:40 +0100 Subject: [PATCH 1/7] Adds posix.timegm(), brother of posix.mktime(). --- lib/posix/posix.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 41260b36fc..e2c4367498 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -2265,6 +2265,7 @@ proc gmtime_r*(a1: var TTime, a2: var Ttm): ptr Ttm {.importc, header: " proc localtime*(a1: var TTime): ptr Ttm {.importc, header: "".} proc localtime_r*(a1: var TTime, a2: var Ttm): ptr Ttm {.importc, header: "".} proc mktime*(a1: var Ttm): TTime {.importc, header: "".} +proc timegm*(a1: var Ttm): TTime {.importc, header: "".} proc nanosleep*(a1, a2: var Ttimespec): cint {.importc, header: "".} proc strftime*(a1: cstring, a2: int, a3: cstring, a4: var Ttm): int {.importc, header: "".} From d8793dcf56b76e3a0cfabbb9a15759a54474777e Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sun, 2 Mar 2014 23:15:30 +0100 Subject: [PATCH 2/7] Avoids crash parsing unknown rst raw directive. Fixes #761. --- lib/packages/docutils/rst.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index bb018bc1e3..30cc9026b4 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -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) From 3249f16d85c2adee46e283e060ce6d1e31464d06 Mon Sep 17 00:00:00 2001 From: Clay Sweetser Date: Sat, 1 Mar 2014 17:41:50 -0500 Subject: [PATCH 3/7] Integrated 'babel' with testament --- tests/testament/categories.nim | 70 +++++++++++++++++++++++++++++++++- tests/testament/specs.nim | 2 + 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 442dd12123..0f6c247165 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -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) diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim index e97015946d..f7982127fa 100644 --- a/tests/testament/specs.nim +++ b/tests/testament/specs.nim @@ -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 From 269bf8e334bd9edfe86b2923fffa157cf35f668d Mon Sep 17 00:00:00 2001 From: Clay Sweetser Date: Mon, 3 Mar 2014 06:26:22 -0500 Subject: [PATCH 4/7] Removed babel package tests from those run when 'all' is specified. --- tests/testament/categories.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 0f6c247165..9dc51567dc 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -290,7 +290,7 @@ proc testBabelPackages(r: var TResults, options: string, cat: Category) = # ---------------------------------------------------------------------------- -const AdditionalCategories = ["debugger", "tools", "examples", "stdlib", "babel"] +const AdditionalCategories = ["debugger", "tools", "examples", "stdlib"] proc `&.?`(a, b: string): string = # candidate for the stdlib? From 9620893d7201184a8635931aee9c684dea0bc5b9 Mon Sep 17 00:00:00 2001 From: Clay Sweetser Date: Mon, 3 Mar 2014 17:53:47 -0500 Subject: [PATCH 5/7] Allowed specification of what babel packages to install via new categories - 'babel-core', 'babel-extra', and 'babel-all' --- tests/testament/categories.nim | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 9dc51567dc..bf65d26dee 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -223,6 +223,10 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) = testNoSpec r, makeTest(test, options, cat, actionCompile) # ----------------------------- babel ---------------------------------------- +type PackageFilter = enum + pfCoreOnly + pfExtraOnly + pfAll let babelExe = findExe("babel") @@ -249,7 +253,7 @@ proc getPackageDir(package: string): string = else: result = commandOutput[0] -iterator listPackages(listAll = false): tuple[name, url: string] = +iterator listPackages(filter: PackageFilter): tuple[name, url: string] = let packageList = parseFile(packageIndex) for package in packageList.items(): @@ -257,18 +261,25 @@ iterator listPackages(listAll = false): tuple[name, url: string] = name = package["name"].str url = package["url"].str isCorePackage = "nimrod-code" in normalize(url) - if isCorePackage or listAll: + 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, options: string, cat: Category) = +proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) = 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) + for name, url in listPackages(filter): + var test = makeTest(name, "", cat) echo(url) let installProcess = startProcess(babelExe, "", ["install", "-y", name]) @@ -290,7 +301,7 @@ proc testBabelPackages(r: var TResults, options: string, cat: Category) = # ---------------------------------------------------------------------------- -const AdditionalCategories = ["debugger", "tools", "examples", "stdlib"] +const AdditionalCategories = ["debugger", "tools", "examples", "stdlib", "babel-core"] proc `&.?`(a, b: string): string = # candidate for the stdlib? @@ -330,8 +341,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": - testBabelPackages(r, 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) From af31f19ebbb042c4ff5c490df9b53f74bab520f3 Mon Sep 17 00:00:00 2001 From: Varriount Date: Mon, 3 Mar 2014 18:43:41 -0500 Subject: [PATCH 6/7] Fix categories.nim --- tests/testament/categories.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index bf65d26dee..627c3d5ea6 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -251,7 +251,7 @@ proc getPackageDir(package: string): string = if commandOutput.exitCode != quitSuccess: return "" else: - result = commandOutput[0] + result = commandOutput[0].string iterator listPackages(filter: PackageFilter): tuple[name, url: string] = let packageList = parseFile(packageIndex) From ab0fea919900be21c0872d1932a4ef90dd440a42 Mon Sep 17 00:00:00 2001 From: Varriount Date: Tue, 4 Mar 2014 10:10:00 -0500 Subject: [PATCH 7/7] Changed behavior when babel cannot be found/run Failure to find and run babel when using the tester now produces a warning message instead of causing the tester to quit. --- tests/testament/categories.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 627c3d5ea6..9bb4838e05 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -273,10 +273,12 @@ iterator listPackages(filter: PackageFilter): tuple[name, url: string] = proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) = if babelExe == "": - quit("Cannot run babel tests: Babel binary not found.", quitFailure) + echo("[Warning] - Cannot run babel tests: Babel binary not found.") + return if execCmd("$# update" % babelExe) == quitFailure: - quit("Cannot run babel tests: Babel update failed.") + echo("[Warning] - Cannot run babel tests: Babel update failed.") + return for name, url in listPackages(filter): var test = makeTest(name, "", cat)