diff options
Diffstat (limited to 'testament/testament.nim')
-rw-r--r-- | testament/testament.nim | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/testament/testament.nim b/testament/testament.nim index da686a0c3..a52c573a7 100644 --- a/testament/testament.nim +++ b/testament/testament.nim @@ -12,7 +12,7 @@ import strutils, pegs, os, osproc, streams, json, backend, parseopt, specs, htmlgen, browsers, terminal, - algorithm, times, md5, sequtils + algorithm, times, md5, sequtils, azure include compiler/nodejs @@ -284,7 +284,7 @@ proc addResult(r: var TResults, test: TTest, target: TTarget, maybeStyledEcho styleBright, given, "\n" - if backendLogging and existsEnv("APPVEYOR"): + if backendLogging and (isAppVeyor or isAzure): let (outcome, msg) = case success of reSuccess: @@ -295,14 +295,17 @@ proc addResult(r: var TResults, test: TTest, target: TTarget, ("Failed", "Failure: " & $success & "\n" & given) else: ("Failed", "Failure: " & $success & "\nExpected:\n" & expected & "\n\n" & "Gotten:\n" & given) - var p = startProcess("appveyor", args=["AddTest", test.name.replace("\\", "/") & test.options, - "-Framework", "nim-testament", "-FileName", - test.cat.string, - "-Outcome", outcome, "-ErrorMessage", msg, - "-Duration", $(duration*1000).int], - options={poStdErrToStdOut, poUsePath, poParentStreams}) - discard waitForExit(p) - close(p) + if isAzure: + azure.addTestResult(name, test.cat.string, int(duration * 1000), msg, success) + else: + var p = startProcess("appveyor", args=["AddTest", test.name.replace("\\", "/") & test.options, + "-Framework", "nim-testament", "-FileName", + test.cat.string, + "-Outcome", outcome, "-ErrorMessage", msg, + "-Duration", $(duration*1000).int], + options={poStdErrToStdOut, poUsePath, poParentStreams}) + discard waitForExit(p) + close(p) proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest, target: TTarget) = if strip(expected.msg) notin strip(given.msg): @@ -645,6 +648,8 @@ proc main() = quit Usage of "skipfrom": skipFrom = p.val.string + of "azurerunid": + runId = p.val.parseInt else: quit Usage p.next() @@ -657,6 +662,7 @@ proc main() = of "all": #processCategory(r, Category"megatest", p.cmdLineRest.string, testsDir, runJoinableTests = false) + azure.start() var myself = quoteShell(findExe("testament" / "testament")) if targetsStr.len > 0: myself &= " " & quoteShell("--targets:" & targetsStr) @@ -665,6 +671,8 @@ proc main() = if skipFrom.len > 0: myself &= " " & quoteShell("--skipFrom:" & skipFrom) + if isAzure: + myself &= " " & quoteShell("--azureRunId:" & $runId) var cats: seq[string] let rest = if p.cmdLineRest.string.len > 0: " " & p.cmdLineRest.string else: "" @@ -690,13 +698,16 @@ proc main() = progressStatus(i) processCategory(r, Category(cati), p.cmdLineRest.string, testsDir, runJoinableTests = false) else: + addQuitProc azure.finish quit osproc.execProcesses(cmds, {poEchoCmd, poStdErrToStdOut, poUsePath, poParentStreams}, beforeRunEvent = progressStatus) of "c", "cat", "category": + azure.start() skips = loadSkipFrom(skipFrom) var cat = Category(p.key) p.next processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = true) of "pcat": + azure.start() skips = loadSkipFrom(skipFrom) # 'pcat' is used for running a category in parallel. Currently the only # difference is that we don't want to run joinable tests here as they @@ -711,6 +722,7 @@ proc main() = p.next processPattern(r, pattern, p.cmdLineRest.string, simulate) of "r", "run": + azure.start() # at least one directory is required in the path, to use as a category name let pathParts = split(p.key.string, {DirSep, AltSep}) # "stdlib/nre/captures.nim" -> "stdlib" + "nre/captures.nim" @@ -726,6 +738,7 @@ proc main() = if action == "html": openDefaultBrowser(resultsFile) else: echo r, r.data backend.close() + if isMainProcess: azure.finish() var failed = r.total - r.passed - r.skipped if failed != 0: echo "FAILURE! total: ", r.total, " passed: ", r.passed, " skipped: ", |