Testament small fixes (#16788)
* ReSync with Devel * ReSync * Fix Deprecations, Convertion to itself, code style, etc * Fix Deprecations, Convertion to itself, code style, etc
This commit is contained in:
parent
3df652b90b
commit
f1d165adf2
6 changed files with 91 additions and 191 deletions
|
|
@ -13,7 +13,6 @@ type
|
||||||
CommitId = distinct string
|
CommitId = distinct string
|
||||||
|
|
||||||
proc `$`*(id: MachineId): string {.borrow.}
|
proc `$`*(id: MachineId): string {.borrow.}
|
||||||
#proc `$`(id: CommitId): string {.borrow.} # not used
|
|
||||||
|
|
||||||
var
|
var
|
||||||
thisMachine: MachineId
|
thisMachine: MachineId
|
||||||
|
|
@ -21,9 +20,9 @@ var
|
||||||
thisBranch: string
|
thisBranch: string
|
||||||
|
|
||||||
proc getMachine*(): MachineId =
|
proc getMachine*(): MachineId =
|
||||||
var name = execProcess("hostname").string.strip
|
var name = execProcess("hostname").strip
|
||||||
if name.len == 0:
|
if name.len == 0:
|
||||||
name = when defined(posix): getEnv("HOSTNAME").string
|
name = when defined(posix): getEnv("HOSTNAME")
|
||||||
else: getEnv("COMPUTERNAME").string
|
else: getEnv("COMPUTERNAME").string
|
||||||
if name.len == 0:
|
if name.len == 0:
|
||||||
quit "cannot determine the machine name"
|
quit "cannot determine the machine name"
|
||||||
|
|
@ -32,8 +31,8 @@ proc getMachine*(): MachineId =
|
||||||
|
|
||||||
proc getCommit(): CommitId =
|
proc getCommit(): CommitId =
|
||||||
const commLen = "commit ".len
|
const commLen = "commit ".len
|
||||||
let hash = execProcess("git log -n 1").string.strip[commLen..commLen+10]
|
let hash = execProcess("git log -n 1").strip[commLen..commLen+10]
|
||||||
thisBranch = execProcess("git symbolic-ref --short HEAD").string.strip
|
thisBranch = execProcess("git symbolic-ref --short HEAD").strip
|
||||||
if hash.len == 0 or thisBranch.len == 0: quit "cannot determine git HEAD"
|
if hash.len == 0 or thisBranch.len == 0: quit "cannot determine git HEAD"
|
||||||
result = CommitId(hash)
|
result = CommitId(hash)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,50 +47,6 @@ proc isTestFile*(file: string): bool =
|
||||||
let (_, name, ext) = splitFile(file)
|
let (_, name, ext) = splitFile(file)
|
||||||
result = ext == ".nim" and name.startsWith("t")
|
result = ext == ".nim" and name.startsWith("t")
|
||||||
|
|
||||||
# ---------------- IC tests ---------------------------------------------
|
|
||||||
|
|
||||||
# xxx deadcode
|
|
||||||
proc icTests(r: var TResults; testsDir: string, cat: Category, options: string) =
|
|
||||||
const
|
|
||||||
tooltests = ["compiler/nim.nim", "tools/nimgrep.nim"]
|
|
||||||
writeOnly = " --incremental:writeonly "
|
|
||||||
readOnly = " --incremental:readonly "
|
|
||||||
incrementalOn = " --incremental:on "
|
|
||||||
|
|
||||||
template test(x: untyped) =
|
|
||||||
testSpecWithNimcache(r, makeRawTest(file, x & options, cat), nimcache)
|
|
||||||
|
|
||||||
template editedTest(x: untyped) =
|
|
||||||
var test = makeTest(file, x & options, cat)
|
|
||||||
test.spec.targets = {getTestSpecTarget()}
|
|
||||||
testSpecWithNimcache(r, test, nimcache)
|
|
||||||
|
|
||||||
const tempExt = "_temp.nim"
|
|
||||||
for it in walkDirRec(testsDir / "ic"):
|
|
||||||
if isTestFile(it) and not it.endsWith(tempExt):
|
|
||||||
let nimcache = nimcacheDir(it, options, getTestSpecTarget())
|
|
||||||
removeDir(nimcache)
|
|
||||||
|
|
||||||
let content = readFile(it)
|
|
||||||
for fragment in content.split("#!EDIT!#"):
|
|
||||||
let file = it.replace(".nim", tempExt)
|
|
||||||
writeFile(file, fragment)
|
|
||||||
let oldPassed = r.passed
|
|
||||||
editedTest incrementalOn
|
|
||||||
if r.passed != oldPassed+1: break
|
|
||||||
|
|
||||||
for file in tooltests:
|
|
||||||
let nimcache = nimcacheDir(file, options, getTestSpecTarget())
|
|
||||||
removeDir(nimcache)
|
|
||||||
|
|
||||||
let oldPassed = r.passed
|
|
||||||
test writeOnly
|
|
||||||
|
|
||||||
if r.passed == oldPassed+1:
|
|
||||||
test readOnly
|
|
||||||
if r.passed == oldPassed+2:
|
|
||||||
test readOnly & "-d:nimBackendAssumesChange "
|
|
||||||
|
|
||||||
# --------------------- flags tests -------------------------------------------
|
# --------------------- flags tests -------------------------------------------
|
||||||
|
|
||||||
proc flagTests(r: var TResults, cat: Category, options: string) =
|
proc flagTests(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
@ -137,7 +93,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) =
|
||||||
# posix relies on crappy LD_LIBRARY_PATH (ugh!):
|
# posix relies on crappy LD_LIBRARY_PATH (ugh!):
|
||||||
const libpathenv = when defined(haiku): "LIBRARY_PATH"
|
const libpathenv = when defined(haiku): "LIBRARY_PATH"
|
||||||
else: "LD_LIBRARY_PATH"
|
else: "LD_LIBRARY_PATH"
|
||||||
var libpath = getEnv(libpathenv).string
|
var libpath = getEnv(libpathenv)
|
||||||
# Temporarily add the lib directory to LD_LIBRARY_PATH:
|
# Temporarily add the lib directory to LD_LIBRARY_PATH:
|
||||||
putEnv(libpathenv, "tests/dll" & (if libpath.len > 0: ":" & libpath else: ""))
|
putEnv(libpathenv, "tests/dll" & (if libpath.len > 0: ":" & libpath else: ""))
|
||||||
defer: putEnv(libpathenv, libpath)
|
defer: putEnv(libpathenv, libpath)
|
||||||
|
|
@ -265,7 +221,7 @@ proc debuggerTests(r: var TResults, cat: Category, options: string) =
|
||||||
t.spec.action = actionCompile
|
t.spec.action = actionCompile
|
||||||
# force target to C because of MacOS 10.15 SDK headers bug
|
# force target to C because of MacOS 10.15 SDK headers bug
|
||||||
# https://github.com/nim-lang/Nim/pull/15612#issuecomment-712471879
|
# https://github.com/nim-lang/Nim/pull/15612#issuecomment-712471879
|
||||||
t.spec.targets = { targetC }
|
t.spec.targets = {targetC}
|
||||||
testSpec r, t
|
testSpec r, t
|
||||||
|
|
||||||
# ------------------------- JS tests ------------------------------------------
|
# ------------------------- JS tests ------------------------------------------
|
||||||
|
|
@ -384,7 +340,7 @@ proc findMainFile(dir: string): string =
|
||||||
var nimFiles = 0
|
var nimFiles = 0
|
||||||
for kind, file in os.walkDir(dir):
|
for kind, file in os.walkDir(dir):
|
||||||
if kind == pcFile:
|
if kind == pcFile:
|
||||||
if file.endsWith(cfgExt): return file[.. ^(cfgExt.len+1)] & ".nim"
|
if file.endsWith(cfgExt): return file[ .. ^(cfgExt.len+1)] & ".nim"
|
||||||
elif file.endsWith(".nim"):
|
elif file.endsWith(".nim"):
|
||||||
if result.len == 0: result = file
|
if result.len == 0: result = file
|
||||||
inc nimFiles
|
inc nimFiles
|
||||||
|
|
@ -429,7 +385,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
|
||||||
|
|
||||||
files.sort # reproducible order
|
files.sort # reproducible order
|
||||||
for testFile in files:
|
for testFile in files:
|
||||||
let contents = readFile(testFile).string
|
let contents = readFile(testFile)
|
||||||
var testObj = makeTest(testFile, options, cat)
|
var testObj = makeTest(testFile, options, cat)
|
||||||
#[
|
#[
|
||||||
todo:
|
todo:
|
||||||
|
|
@ -445,7 +401,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
|
||||||
|
|
||||||
# ----------------------------- nimble ----------------------------------------
|
# ----------------------------- nimble ----------------------------------------
|
||||||
|
|
||||||
var nimbleDir = getEnv("NIMBLE_DIR").string
|
var nimbleDir = getEnv("NIMBLE_DIR")
|
||||||
if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble"
|
if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble"
|
||||||
let
|
let
|
||||||
nimbleExe = findExe("nimble")
|
nimbleExe = findExe("nimble")
|
||||||
|
|
@ -606,15 +562,6 @@ proc isJoinableSpec(spec: TSpec): bool =
|
||||||
if spec.file.readFile.contains "when isMainModule":
|
if spec.file.readFile.contains "when isMainModule":
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
when false:
|
|
||||||
proc norm(s: var string) =
|
|
||||||
## strip empty newlines
|
|
||||||
while true:
|
|
||||||
let tmp = s.replace("\n\n", "\n")
|
|
||||||
if tmp == s: break
|
|
||||||
s = tmp
|
|
||||||
s = s.strip
|
|
||||||
|
|
||||||
proc quoted(a: string): string =
|
proc quoted(a: string): string =
|
||||||
# todo: consider moving to system.nim
|
# todo: consider moving to system.nim
|
||||||
result.addQuoted(a)
|
result.addQuoted(a)
|
||||||
|
|
@ -632,8 +579,8 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
if isJoinableSpec(spec):
|
if isJoinableSpec(spec):
|
||||||
specs.add spec
|
specs.add spec
|
||||||
|
|
||||||
proc cmp(a: TSpec, b:TSpec): auto = cmp(a.file, b.file)
|
proc cmp(a: TSpec, b: TSpec): auto = cmp(a.file, b.file)
|
||||||
sort(specs, cmp=cmp) # reproducible order
|
sort(specs, cmp = cmp) # reproducible order
|
||||||
echo "joinable specs: ", specs.len
|
echo "joinable specs: ", specs.len
|
||||||
|
|
||||||
if simulate:
|
if simulate:
|
||||||
|
|
@ -663,17 +610,17 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
let args = ["c", "--nimCache:" & outDir, "-d:testing", "-d:nimMegatest", "--listCmd", "--path:" & root, megatestFile]
|
let args = ["c", "--nimCache:" & outDir, "-d:testing", "-d:nimMegatest", "--listCmd", "--path:" & root, megatestFile]
|
||||||
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
|
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
echo "$ " & cmdLine & "\n" & buf.string
|
echo "$ " & cmdLine & "\n" & buf
|
||||||
quit(failString & "megatest compilation failed")
|
quit(failString & "megatest compilation failed")
|
||||||
|
|
||||||
(buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).dup normalizeExe)
|
(buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).dup normalizeExe)
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
echo buf.string
|
echo buf
|
||||||
quit(failString & "megatest execution failed")
|
quit(failString & "megatest execution failed")
|
||||||
|
|
||||||
const outputExceptedFile = "outputExpected.txt"
|
const outputExceptedFile = "outputExpected.txt"
|
||||||
const outputGottenFile = "outputGotten.txt"
|
const outputGottenFile = "outputGotten.txt"
|
||||||
writeFile(outputGottenFile, buf.string)
|
writeFile(outputGottenFile, buf)
|
||||||
var outputExpected = ""
|
var outputExpected = ""
|
||||||
for i, runSpec in specs:
|
for i, runSpec in specs:
|
||||||
outputExpected.add marker & runSpec.file & "\n"
|
outputExpected.add marker & runSpec.file & "\n"
|
||||||
|
|
@ -682,7 +629,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
if not runSpec.output.endsWith "\n":
|
if not runSpec.output.endsWith "\n":
|
||||||
outputExpected.add '\n'
|
outputExpected.add '\n'
|
||||||
|
|
||||||
if buf.string != outputExpected:
|
if buf != outputExpected:
|
||||||
writeFile(outputExceptedFile, outputExpected)
|
writeFile(outputExceptedFile, outputExpected)
|
||||||
discard execShellCmd("diff -uNdr $1 $2" % [outputExceptedFile, outputGottenFile])
|
discard execShellCmd("diff -uNdr $1 $2" % [outputExceptedFile, outputGottenFile])
|
||||||
echo failString & "megatest output different!"
|
echo failString & "megatest output different!"
|
||||||
|
|
@ -690,10 +637,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
quit 1
|
quit 1
|
||||||
else:
|
else:
|
||||||
echo "megatest output OK"
|
echo "megatest output OK"
|
||||||
when false: # no point removing those, always good for debugging
|
|
||||||
removeFile(outputGottenFile)
|
|
||||||
removeFile(megatestFile) # keep it around
|
|
||||||
#testSpec r, makeTest("megatest", options, cat)
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -701,9 +645,6 @@ proc processCategory(r: var TResults, cat: Category,
|
||||||
options, testsDir: string,
|
options, testsDir: string,
|
||||||
runJoinableTests: bool) =
|
runJoinableTests: bool) =
|
||||||
case cat.string.normalize
|
case cat.string.normalize
|
||||||
of "ic":
|
|
||||||
when false:
|
|
||||||
icTests(r, testsDir, cat, options)
|
|
||||||
of "js":
|
of "js":
|
||||||
# only run the JS tests on Windows or Linux because Travis is bad
|
# only run the JS tests on Windows or Linux because Travis is bad
|
||||||
# and other OSes like Haiku might lack nodejs:
|
# and other OSes like Haiku might lack nodejs:
|
||||||
|
|
|
||||||
|
|
@ -11,26 +11,24 @@ proc mismatch*[T](lhs: T, rhs: T): string =
|
||||||
|
|
||||||
proc quoted(s: string): string = result.addQuoted s
|
proc quoted(s: string): string = result.addQuoted s
|
||||||
|
|
||||||
result.add "\n"
|
result.add '\n'
|
||||||
result.add "lhs:{" & replaceInvisible(
|
result.add "lhs:{" & replaceInvisible(
|
||||||
$lhs) & "}\nrhs:{" & replaceInvisible($rhs) & "}\n"
|
$lhs) & "}\nrhs:{" & replaceInvisible($rhs) & "}\n"
|
||||||
when compiles(lhs.len):
|
when compiles(lhs.len):
|
||||||
if lhs.len != rhs.len:
|
if lhs.len != rhs.len:
|
||||||
result.add "lhs.len: " & $lhs.len & " rhs.len: " & $rhs.len & "\n"
|
result.add "lhs.len: " & $lhs.len & " rhs.len: " & $rhs.len & '\n'
|
||||||
when compiles(lhs[0]):
|
when compiles(lhs[0]):
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < lhs.len and i < rhs.len:
|
while i < lhs.len and i < rhs.len:
|
||||||
if lhs[i] != rhs[i]: break
|
if lhs[i] != rhs[i]: break
|
||||||
i.inc
|
i.inc
|
||||||
result.add "first mismatch index: " & $i & "\n"
|
result.add "first mismatch index: " & $i & '\n'
|
||||||
if i < lhs.len and i < rhs.len:
|
if i < lhs.len and i < rhs.len:
|
||||||
result.add "lhs[i]: {" & quoted($lhs[i]) & "}\nrhs[i]: {" & quoted(
|
result.add "lhs[i]: {" & quoted($lhs[i]) & "}\nrhs[i]: {" & quoted(
|
||||||
$rhs[i]) & "}\n"
|
$rhs[i]) & "}\n"
|
||||||
result.add "lhs[0..<i]:{" & replaceInvisible($lhs[
|
result.add "lhs[0..<i]:{" & replaceInvisible($lhs[
|
||||||
0..<i]) & "}"
|
0..<i]) & '}'
|
||||||
|
|
||||||
proc assertEquals*[T](lhs: T, rhs: T, msg = "") =
|
proc assertEquals*[T](lhs: T, rhs: T, msg = "") =
|
||||||
when false: # can be useful for debugging to see all that's fed to this.
|
if lhs != rhs:
|
||||||
echo "----" & $lhs
|
doAssert false, mismatch(lhs, rhs) & '\n' & msg
|
||||||
if lhs!=rhs:
|
|
||||||
doAssert false, mismatch(lhs, rhs) & "\n" & msg
|
|
||||||
|
|
|
||||||
|
|
@ -34,27 +34,27 @@ type
|
||||||
|
|
||||||
TOutputCheck* = enum
|
TOutputCheck* = enum
|
||||||
ocIgnore = "ignore"
|
ocIgnore = "ignore"
|
||||||
ocEqual = "equal"
|
ocEqual = "equal"
|
||||||
ocSubstr = "substr"
|
ocSubstr = "substr"
|
||||||
|
|
||||||
TResultEnum* = enum
|
TResultEnum* = enum
|
||||||
reNimcCrash, # nim compiler seems to have crashed
|
reNimcCrash, # nim compiler seems to have crashed
|
||||||
reMsgsDiffer, # error messages differ
|
reMsgsDiffer, # error messages differ
|
||||||
reFilesDiffer, # expected and given filenames differ
|
reFilesDiffer, # expected and given filenames differ
|
||||||
reLinesDiffer, # expected and given line numbers differ
|
reLinesDiffer, # expected and given line numbers differ
|
||||||
reOutputsDiffer,
|
reOutputsDiffer,
|
||||||
reExitcodesDiffer, # exit codes of program or of valgrind differ
|
reExitcodesDiffer, # exit codes of program or of valgrind differ
|
||||||
reTimeout,
|
reTimeout,
|
||||||
reInvalidPeg,
|
reInvalidPeg,
|
||||||
reCodegenFailure,
|
reCodegenFailure,
|
||||||
reCodeNotFound,
|
reCodeNotFound,
|
||||||
reExeNotFound,
|
reExeNotFound,
|
||||||
reInstallFailed # package installation failed
|
reInstallFailed # package installation failed
|
||||||
reBuildFailed # package building failed
|
reBuildFailed # package building failed
|
||||||
reDisabled, # test is disabled
|
reDisabled, # test is disabled
|
||||||
reJoined, # test is disabled because it was joined into the megatest
|
reJoined, # test is disabled because it was joined into the megatest
|
||||||
reSuccess # test was successful
|
reSuccess # test was successful
|
||||||
reInvalidSpec # test had problems to parse the spec
|
reInvalidSpec # test had problems to parse the spec
|
||||||
|
|
||||||
TTarget* = enum
|
TTarget* = enum
|
||||||
targetC = "c"
|
targetC = "c"
|
||||||
|
|
@ -90,7 +90,7 @@ type
|
||||||
targets*: set[TTarget]
|
targets*: set[TTarget]
|
||||||
matrix*: seq[string]
|
matrix*: seq[string]
|
||||||
nimout*: string
|
nimout*: string
|
||||||
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
||||||
unjoinable*: bool
|
unjoinable*: bool
|
||||||
unbatchable*: bool
|
unbatchable*: bool
|
||||||
# whether this test can be batchable via `NIM_TESTAMENT_BATCH`; only very
|
# whether this test can be batchable via `NIM_TESTAMENT_BATCH`; only very
|
||||||
|
|
@ -98,7 +98,7 @@ type
|
||||||
# by making the dependencies explicit
|
# by making the dependencies explicit
|
||||||
useValgrind*: ValgrindSpec
|
useValgrind*: ValgrindSpec
|
||||||
timeout*: float # in seconds, fractions possible,
|
timeout*: float # in seconds, fractions possible,
|
||||||
# but don't rely on much precision
|
# but don't rely on much precision
|
||||||
inlineErrors*: seq[InlineError] # line information to error message
|
inlineErrors*: seq[InlineError] # line information to error message
|
||||||
|
|
||||||
proc getCmd*(s: TSpec): string =
|
proc getCmd*(s: TSpec): string =
|
||||||
|
|
@ -180,7 +180,7 @@ proc extractErrorMsg(s: string; i: int; line: var int; col: var int; spec: var T
|
||||||
proc extractSpec(filename: string; spec: var TSpec): string =
|
proc extractSpec(filename: string; spec: var TSpec): string =
|
||||||
const
|
const
|
||||||
tripleQuote = "\"\"\""
|
tripleQuote = "\"\"\""
|
||||||
var s = readFile(filename).string
|
var s = readFile(filename)
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
var a = -1
|
var a = -1
|
||||||
|
|
@ -225,7 +225,7 @@ proc addLine*(self: var string; a: string) =
|
||||||
self.add a
|
self.add a
|
||||||
self.add "\n"
|
self.add "\n"
|
||||||
|
|
||||||
proc addLine*(self: var string; a,b: string) =
|
proc addLine*(self: var string; a, b: string) =
|
||||||
self.add a
|
self.add a
|
||||||
self.add b
|
self.add b
|
||||||
self.add "\n"
|
self.add "\n"
|
||||||
|
|
@ -233,7 +233,7 @@ proc addLine*(self: var string; a,b: string) =
|
||||||
proc initSpec*(filename: string): TSpec =
|
proc initSpec*(filename: string): TSpec =
|
||||||
result.file = filename
|
result.file = filename
|
||||||
|
|
||||||
proc isCurrentBatch(testamentData: TestamentData, filename: string): bool =
|
proc isCurrentBatch(testamentData: TestamentData; filename: string): bool =
|
||||||
if testamentData.testamentNumBatch != 0:
|
if testamentData.testamentNumBatch != 0:
|
||||||
hash(filename) mod testamentData.testamentNumBatch == testamentData.testamentBatch
|
hash(filename) mod testamentData.testamentNumBatch == testamentData.testamentBatch
|
||||||
else:
|
else:
|
||||||
|
|
@ -297,7 +297,7 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.output = strip(e.value)
|
result.output = strip(e.value)
|
||||||
of "sortoutput":
|
of "sortoutput":
|
||||||
try:
|
try:
|
||||||
result.sortoutput = parseCfgBool(e.value)
|
result.sortoutput = parseCfgBool(e.value)
|
||||||
except:
|
except:
|
||||||
result.parseErrors.addLine getCurrentExceptionMsg()
|
result.parseErrors.addLine getCurrentExceptionMsg()
|
||||||
of "exitcode":
|
of "exitcode":
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@
|
||||||
## This program verifies Nim against the testcases.
|
## This program verifies Nim against the testcases.
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils, pegs, os, osproc, streams, json,
|
strutils, pegs, os, osproc, streams, json, std/exitprocs,
|
||||||
backend, parseopt, specs, htmlgen, browsers, terminal,
|
backend, parseopt, specs, htmlgen, browsers, terminal,
|
||||||
algorithm, times, md5, sequtils, azure, intsets
|
algorithm, times, md5, sequtils, azure, intsets, macros
|
||||||
from std/sugar import dup
|
from std/sugar import dup
|
||||||
import compiler/nodejs
|
import compiler/nodejs
|
||||||
import lib/stdtest/testutils
|
import lib/stdtest/testutils
|
||||||
|
|
@ -26,7 +26,6 @@ const
|
||||||
failString* = "FAIL: " # ensures all failures can be searched with 1 keyword in CI logs
|
failString* = "FAIL: " # ensures all failures can be searched with 1 keyword in CI logs
|
||||||
testsDir = "tests" & DirSep
|
testsDir = "tests" & DirSep
|
||||||
resultsFile = "testresults.html"
|
resultsFile = "testresults.html"
|
||||||
#jsonFile = "testresults.json" # not used
|
|
||||||
Usage = """Usage:
|
Usage = """Usage:
|
||||||
testament [options] command [arguments]
|
testament [options] command [arguments]
|
||||||
|
|
||||||
|
|
@ -89,13 +88,6 @@ proc isSuccess(input: string): bool =
|
||||||
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
|
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
|
||||||
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
||||||
|
|
||||||
when false: # deadcode
|
|
||||||
proc normalizeMsg(s: string): string =
|
|
||||||
result = newStringOfCap(s.len+1)
|
|
||||||
for x in splitLines(s):
|
|
||||||
if result.len > 0: result.add '\L'
|
|
||||||
result.add x.strip
|
|
||||||
|
|
||||||
proc getFileDir(filename: string): string =
|
proc getFileDir(filename: string): string =
|
||||||
result = filename.splitFile().dir
|
result = filename.splitFile().dir
|
||||||
if not result.isAbsolute():
|
if not result.isAbsolute():
|
||||||
|
|
@ -111,8 +103,8 @@ proc execCmdEx2(command: string, args: openArray[string]; workingDir, input: str
|
||||||
for arg in args:
|
for arg in args:
|
||||||
result.cmdLine.add ' '
|
result.cmdLine.add ' '
|
||||||
result.cmdLine.add quoteShell(arg)
|
result.cmdLine.add quoteShell(arg)
|
||||||
var p = startProcess(command, workingDir=workingDir, args=args,
|
var p = startProcess(command, workingDir = workingDir, args = args,
|
||||||
options={poStdErrToStdOut, poUsePath})
|
options = {poStdErrToStdOut, poUsePath})
|
||||||
var outp = outputStream(p)
|
var outp = outputStream(p)
|
||||||
|
|
||||||
# There is no way to provide input for the child process
|
# There is no way to provide input for the child process
|
||||||
|
|
@ -122,12 +114,12 @@ proc execCmdEx2(command: string, args: openArray[string]; workingDir, input: str
|
||||||
instream.write(input)
|
instream.write(input)
|
||||||
close instream
|
close instream
|
||||||
|
|
||||||
result.exitCode = -1
|
result.exitCode = -1
|
||||||
var line = newStringOfCap(120)
|
var line = newStringOfCap(120)
|
||||||
while true:
|
while true:
|
||||||
if outp.readLine(line):
|
if outp.readLine(line):
|
||||||
result.output.string.add(line.string)
|
result.output.add line
|
||||||
result.output.string.add("\n")
|
result.output.add '\n'
|
||||||
else:
|
else:
|
||||||
result.exitCode = peekExitCode(p)
|
result.exitCode = peekExitCode(p)
|
||||||
if result.exitCode != -1: break
|
if result.exitCode != -1: break
|
||||||
|
|
@ -140,10 +132,10 @@ proc nimcacheDir(filename, options: string, target: TTarget): string =
|
||||||
|
|
||||||
proc prepareTestArgs(cmdTemplate, filename, options, nimcache: string,
|
proc prepareTestArgs(cmdTemplate, filename, options, nimcache: string,
|
||||||
target: TTarget, extraOptions = ""): seq[string] =
|
target: TTarget, extraOptions = ""): seq[string] =
|
||||||
var options = target.defaultOptions & " " & options
|
var options = target.defaultOptions & ' ' & options
|
||||||
# improve pending https://github.com/nim-lang/Nim/issues/14343
|
# improve pending https://github.com/nim-lang/Nim/issues/14343
|
||||||
if nimcache.len > 0: options.add " " & ("--nimCache:" & nimcache).quoteShell
|
if nimcache.len > 0: options.add ' ' & ("--nimCache:" & nimcache).quoteShell
|
||||||
options.add " " & extraOptions
|
options.add ' ' & extraOptions
|
||||||
result = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
result = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||||
"options", options, "file", filename.quoteShell,
|
"options", options, "file", filename.quoteShell,
|
||||||
"filedir", filename.getFileDir(), "nim", compilerPrefix])
|
"filedir", filename.getFileDir(), "nim", compilerPrefix])
|
||||||
|
|
@ -153,8 +145,8 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string,
|
||||||
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache, target,
|
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache, target,
|
||||||
extraOptions)
|
extraOptions)
|
||||||
result.cmd = quoteShellCommand(c)
|
result.cmd = quoteShellCommand(c)
|
||||||
var p = startProcess(command=c[0], args=c[1 .. ^1],
|
var p = startProcess(command = c[0], args = c[1 .. ^1],
|
||||||
options={poStdErrToStdOut, poUsePath})
|
options = {poStdErrToStdOut, poUsePath})
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
var suc = ""
|
var suc = ""
|
||||||
var err = ""
|
var err = ""
|
||||||
|
|
@ -163,7 +155,7 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string,
|
||||||
result.nimout = ""
|
result.nimout = ""
|
||||||
while true:
|
while true:
|
||||||
if outp.readLine(x):
|
if outp.readLine(x):
|
||||||
result.nimout.add(x & "\n")
|
result.nimout.add(x & '\n')
|
||||||
if x =~ pegOfInterest:
|
if x =~ pegOfInterest:
|
||||||
# `err` should contain the last error/warning message
|
# `err` should contain the last error/warning message
|
||||||
err = x
|
err = x
|
||||||
|
|
@ -201,8 +193,8 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string,
|
||||||
proc callCCompiler(cmdTemplate, filename, options: string,
|
proc callCCompiler(cmdTemplate, filename, options: string,
|
||||||
target: TTarget): TSpec =
|
target: TTarget): TSpec =
|
||||||
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache = "", target)
|
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache = "", target)
|
||||||
var p = startProcess(command="gcc", args=c[5 .. ^1],
|
var p = startProcess(command = "gcc", args = c[5 .. ^1],
|
||||||
options={poStdErrToStdOut, poUsePath})
|
options = {poStdErrToStdOut, poUsePath})
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
var x = newStringOfCap(120)
|
var x = newStringOfCap(120)
|
||||||
result.nimout = ""
|
result.nimout = ""
|
||||||
|
|
@ -212,7 +204,7 @@ proc callCCompiler(cmdTemplate, filename, options: string,
|
||||||
result.line = -1
|
result.line = -1
|
||||||
while true:
|
while true:
|
||||||
if outp.readLine(x):
|
if outp.readLine(x):
|
||||||
result.nimout.add(x & "\n")
|
result.nimout.add(x & '\n')
|
||||||
elif not running(p):
|
elif not running(p):
|
||||||
break
|
break
|
||||||
close(p)
|
close(p)
|
||||||
|
|
@ -225,8 +217,6 @@ proc initResults: TResults =
|
||||||
result.skipped = 0
|
result.skipped = 0
|
||||||
result.data = ""
|
result.data = ""
|
||||||
|
|
||||||
import macros
|
|
||||||
|
|
||||||
macro ignoreStyleEcho(args: varargs[typed]): untyped =
|
macro ignoreStyleEcho(args: varargs[typed]): untyped =
|
||||||
let typForegroundColor = bindSym"ForegroundColor".getType
|
let typForegroundColor = bindSym"ForegroundColor".getType
|
||||||
let typBackgroundColor = bindSym"BackgroundColor".getType
|
let typBackgroundColor = bindSym"BackgroundColor".getType
|
||||||
|
|
@ -260,8 +250,8 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||||
# test.name is easier to find than test.name.extractFilename
|
# test.name is easier to find than test.name.extractFilename
|
||||||
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
|
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
|
||||||
var name = test.name.replace(DirSep, '/')
|
var name = test.name.replace(DirSep, '/')
|
||||||
name.add " " & $target
|
name.add ' ' & $target
|
||||||
if test.options.len > 0: name.add " " & test.options
|
if test.options.len > 0: name.add ' ' & test.options
|
||||||
|
|
||||||
let duration = epochTime() - test.startTime
|
let duration = epochTime() - test.startTime
|
||||||
let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout
|
let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout
|
||||||
|
|
@ -278,7 +268,7 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||||
given = given)
|
given = given)
|
||||||
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
|
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
|
||||||
template disp(msg) =
|
template disp(msg) =
|
||||||
maybeStyledEcho styleDim, fgYellow, msg & " ", styleBright, fgCyan, name
|
maybeStyledEcho styleDim, fgYellow, msg & ' ', styleBright, fgCyan, name
|
||||||
if success == reSuccess:
|
if success == reSuccess:
|
||||||
maybeStyledEcho fgGreen, "PASS: ", fgCyan, alignLeft(name, 60), fgBlue, " (", durationStr, " sec)"
|
maybeStyledEcho fgGreen, "PASS: ", fgCyan, alignLeft(name, 60), fgBlue, " (", durationStr, " sec)"
|
||||||
elif success == reDisabled:
|
elif success == reDisabled:
|
||||||
|
|
@ -307,18 +297,18 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||||
of reDisabled, reJoined:
|
of reDisabled, reJoined:
|
||||||
("Skipped", "")
|
("Skipped", "")
|
||||||
of reBuildFailed, reNimcCrash, reInstallFailed:
|
of reBuildFailed, reNimcCrash, reInstallFailed:
|
||||||
("Failed", "Failure: " & $success & "\n" & given)
|
("Failed", "Failure: " & $success & '\n' & given)
|
||||||
else:
|
else:
|
||||||
("Failed", "Failure: " & $success & "\nExpected:\n" & expected & "\n\n" & "Gotten:\n" & given)
|
("Failed", "Failure: " & $success & "\nExpected:\n" & expected & "\n\n" & "Gotten:\n" & given)
|
||||||
if isAzure:
|
if isAzure:
|
||||||
azure.addTestResult(name, test.cat.string, int(duration * 1000), msg, success)
|
azure.addTestResult(name, test.cat.string, int(duration * 1000), msg, success)
|
||||||
else:
|
else:
|
||||||
var p = startProcess("appveyor", args=["AddTest", test.name.replace("\\", "/") & test.options,
|
var p = startProcess("appveyor", args = ["AddTest", test.name.replace("\\", "/") & test.options,
|
||||||
"-Framework", "nim-testament", "-FileName",
|
"-Framework", "nim-testament", "-FileName",
|
||||||
test.cat.string,
|
test.cat.string,
|
||||||
"-Outcome", outcome, "-ErrorMessage", msg,
|
"-Outcome", outcome, "-ErrorMessage", msg,
|
||||||
"-Duration", $(duration*1000).int],
|
"-Duration", $(duration * 1000).int],
|
||||||
options={poStdErrToStdOut, poUsePath, poParentStreams})
|
options = {poStdErrToStdOut, poUsePath, poParentStreams})
|
||||||
discard waitForExit(p)
|
discard waitForExit(p)
|
||||||
close(p)
|
close(p)
|
||||||
|
|
||||||
|
|
@ -346,7 +336,7 @@ proc checkForInlineErrors(r: var TResults, expected, given: TSpec, test: TTest,
|
||||||
for j in 0..high(expected.inlineErrors):
|
for j in 0..high(expected.inlineErrors):
|
||||||
if j notin covered:
|
if j notin covered:
|
||||||
var e = test.name
|
var e = test.name
|
||||||
e.add "("
|
e.add '('
|
||||||
e.addInt expected.inlineErrors[j].line
|
e.addInt expected.inlineErrors[j].line
|
||||||
if expected.inlineErrors[j].col > 0:
|
if expected.inlineErrors[j].col > 0:
|
||||||
e.add ", "
|
e.add ", "
|
||||||
|
|
@ -404,7 +394,7 @@ proc codegenCheck(test: TTest, target: TTarget, spec: TSpec, expectedMsg: var st
|
||||||
given: var TSpec) =
|
given: var TSpec) =
|
||||||
try:
|
try:
|
||||||
let genFile = generatedFile(test, target)
|
let genFile = generatedFile(test, target)
|
||||||
let contents = readFile(genFile).string
|
let contents = readFile(genFile)
|
||||||
for check in spec.ccodeCheck:
|
for check in spec.ccodeCheck:
|
||||||
if check.len > 0 and check[0] == '\\':
|
if check.len > 0 and check[0] == '\\':
|
||||||
# little hack to get 'match' support:
|
# little hack to get 'match' support:
|
||||||
|
|
@ -441,12 +431,12 @@ proc compilerOutputTests(test: TTest, target: TTarget, given: var TSpec,
|
||||||
givenmsg = given.nimout.strip
|
givenmsg = given.nimout.strip
|
||||||
nimoutCheck(test, expectedmsg, given)
|
nimoutCheck(test, expectedmsg, given)
|
||||||
else:
|
else:
|
||||||
givenmsg = "$ " & given.cmd & "\n" & given.nimout
|
givenmsg = "$ " & given.cmd & '\n' & given.nimout
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
r.addResult(test, target, expectedmsg, givenmsg, given.err)
|
r.addResult(test, target, expectedmsg, givenmsg, given.err)
|
||||||
|
|
||||||
proc getTestSpecTarget(): TTarget =
|
proc getTestSpecTarget(): TTarget =
|
||||||
if getEnv("NIM_COMPILE_TO_CPP", "false").string == "true":
|
if getEnv("NIM_COMPILE_TO_CPP", "false") == "true":
|
||||||
result = targetCpp
|
result = targetCpp
|
||||||
else:
|
else:
|
||||||
result = targetC
|
result = targetC
|
||||||
|
|
@ -479,7 +469,7 @@ proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec,
|
||||||
var given = callCompiler(expected.getCmd, test.name, test.options,
|
var given = callCompiler(expected.getCmd, test.name, test.options,
|
||||||
nimcache, target, extraOptions)
|
nimcache, target, extraOptions)
|
||||||
if given.err != reSuccess:
|
if given.err != reSuccess:
|
||||||
r.addResult(test, target, "", "$ " & given.cmd & "\n" & given.nimout, given.err)
|
r.addResult(test, target, "", "$ " & given.cmd & '\n' & given.nimout, given.err)
|
||||||
else:
|
else:
|
||||||
let isJsTarget = target == targetJS
|
let isJsTarget = target == targetJS
|
||||||
var exeFile = changeFileExt(test.name, if isJsTarget: "js" else: ExeExt)
|
var exeFile = changeFileExt(test.name, if isJsTarget: "js" else: ExeExt)
|
||||||
|
|
@ -511,13 +501,13 @@ proc testSpecHelper(r: var TResults, test: var TTest, expected: TSpec,
|
||||||
if exitCode != 0: exitCode = 1
|
if exitCode != 0: exitCode = 1
|
||||||
let bufB =
|
let bufB =
|
||||||
if expected.sortoutput:
|
if expected.sortoutput:
|
||||||
var buf2 = buf.string
|
var buf2 = buf
|
||||||
buf2.stripLineEnd
|
buf2.stripLineEnd
|
||||||
var x = splitLines(buf2)
|
var x = splitLines(buf2)
|
||||||
sort(x, system.cmp)
|
sort(x, system.cmp)
|
||||||
join(x, "\n") & "\n"
|
join(x, "\n") & '\n'
|
||||||
else:
|
else:
|
||||||
buf.string
|
buf
|
||||||
if exitCode != expected.exitCode:
|
if exitCode != expected.exitCode:
|
||||||
r.addResult(test, target, "exitcode: " & $expected.exitCode,
|
r.addResult(test, target, "exitcode: " & $expected.exitCode,
|
||||||
"exitcode: " & $exitCode & "\n\nOutput:\n" &
|
"exitcode: " & $exitCode & "\n\nOutput:\n" &
|
||||||
|
|
@ -566,7 +556,7 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
else:
|
else:
|
||||||
targetHelper(r, test, expected)
|
targetHelper(r, test, expected)
|
||||||
|
|
||||||
proc testSpecWithNimcache(r: var TResults, test: TTest; nimcache: string) =
|
proc testSpecWithNimcache(r: var TResults, test: TTest; nimcache: string) {.used.} =
|
||||||
if not checkDisabled(r, test): return
|
if not checkDisabled(r, test): return
|
||||||
for target in test.spec.targets:
|
for target in test.spec.targets:
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
|
|
@ -600,7 +590,7 @@ proc testExec(r: var TResults, test: TTest) =
|
||||||
given.err = reSuccess
|
given.err = reSuccess
|
||||||
else:
|
else:
|
||||||
given.err = reExitcodesDiffer
|
given.err = reExitcodesDiffer
|
||||||
given.msg = outp.string
|
given.msg = outp
|
||||||
|
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
r.addResult(test, targetC, "", given.msg, given.err)
|
r.addResult(test, targetC, "", given.msg, given.err)
|
||||||
|
|
@ -612,7 +602,7 @@ proc makeTest(test, options: string, cat: Category): TTest =
|
||||||
result.spec = parseSpec(addFileExt(test, ".nim"))
|
result.spec = parseSpec(addFileExt(test, ".nim"))
|
||||||
result.startTime = epochTime()
|
result.startTime = epochTime()
|
||||||
|
|
||||||
proc makeRawTest(test, options: string, cat: Category): TTest =
|
proc makeRawTest(test, options: string, cat: Category): TTest {.used.} =
|
||||||
result.cat = cat
|
result.cat = cat
|
||||||
result.name = test
|
result.name = test
|
||||||
result.options = options
|
result.options = options
|
||||||
|
|
@ -659,7 +649,7 @@ proc loadSkipFrom(name: string): seq[string] =
|
||||||
# used by `nlvm` (at least)
|
# used by `nlvm` (at least)
|
||||||
for line in lines(name):
|
for line in lines(name):
|
||||||
let sline = line.strip()
|
let sline = line.strip()
|
||||||
if sline.len > 0 and not sline.startsWith("#"):
|
if sline.len > 0 and not sline.startsWith('#'):
|
||||||
result.add sline
|
result.add sline
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
|
|
@ -675,20 +665,20 @@ proc main() =
|
||||||
var p = initOptParser()
|
var p = initOptParser()
|
||||||
p.next()
|
p.next()
|
||||||
while p.kind in {cmdLongOption, cmdShortOption}:
|
while p.kind in {cmdLongOption, cmdShortOption}:
|
||||||
case p.key.string.normalize
|
case p.key.normalize
|
||||||
of "print", "verbose": optPrintResults = true
|
of "print", "verbose": optPrintResults = true
|
||||||
of "failing": optFailing = true
|
of "failing": optFailing = true
|
||||||
of "pedantic": discard "now always enabled"
|
of "pedantic": discard "now always enabled"
|
||||||
of "targets":
|
of "targets":
|
||||||
targetsStr = p.val.string
|
targetsStr = p.val
|
||||||
gTargets = parseTargets(targetsStr)
|
gTargets = parseTargets(targetsStr)
|
||||||
targetsSet = true
|
targetsSet = true
|
||||||
of "nim":
|
of "nim":
|
||||||
compilerPrefix = addFileExt(p.val.string.absolutePath, ExeExt)
|
compilerPrefix = addFileExt(p.val.absolutePath, ExeExt)
|
||||||
of "directory":
|
of "directory":
|
||||||
setCurrentDir(p.val.string)
|
setCurrentDir(p.val)
|
||||||
of "colors":
|
of "colors":
|
||||||
case p.val.string:
|
case p.val:
|
||||||
of "on":
|
of "on":
|
||||||
useColors = true
|
useColors = true
|
||||||
of "off":
|
of "off":
|
||||||
|
|
@ -707,7 +697,7 @@ proc main() =
|
||||||
of "simulate":
|
of "simulate":
|
||||||
simulate = true
|
simulate = true
|
||||||
of "megatest":
|
of "megatest":
|
||||||
case p.val.string:
|
case p.val:
|
||||||
of "on":
|
of "on":
|
||||||
useMegatest = true
|
useMegatest = true
|
||||||
of "off":
|
of "off":
|
||||||
|
|
@ -715,7 +705,7 @@ proc main() =
|
||||||
else:
|
else:
|
||||||
quit Usage
|
quit Usage
|
||||||
of "backendlogging":
|
of "backendlogging":
|
||||||
case p.val.string:
|
case p.val:
|
||||||
of "on":
|
of "on":
|
||||||
backendLogging = true
|
backendLogging = true
|
||||||
of "off":
|
of "off":
|
||||||
|
|
@ -723,13 +713,13 @@ proc main() =
|
||||||
else:
|
else:
|
||||||
quit Usage
|
quit Usage
|
||||||
of "skipfrom":
|
of "skipfrom":
|
||||||
skipFrom = p.val.string
|
skipFrom = p.val
|
||||||
else:
|
else:
|
||||||
quit Usage
|
quit Usage
|
||||||
p.next()
|
p.next()
|
||||||
if p.kind != cmdArgument:
|
if p.kind != cmdArgument:
|
||||||
quit Usage
|
quit Usage
|
||||||
var action = p.key.string.normalize
|
var action = p.key.normalize
|
||||||
p.next()
|
p.next()
|
||||||
var r = initResults()
|
var r = initResults()
|
||||||
case action
|
case action
|
||||||
|
|
@ -748,7 +738,7 @@ proc main() =
|
||||||
myself &= " " & quoteShell("--skipFrom:" & skipFrom)
|
myself &= " " & quoteShell("--skipFrom:" & skipFrom)
|
||||||
|
|
||||||
var cats: seq[string]
|
var cats: seq[string]
|
||||||
let rest = if p.cmdLineRest.string.len > 0: " " & p.cmdLineRest.string else: ""
|
let rest = if p.cmdLineRest.len > 0: " " & p.cmdLineRest else: ""
|
||||||
for kind, dir in walkDir(testsDir):
|
for kind, dir in walkDir(testsDir):
|
||||||
assert testsDir.startsWith(testsDir)
|
assert testsDir.startsWith(testsDir)
|
||||||
let cat = dir[testsDir.len .. ^1]
|
let cat = dir[testsDir.len .. ^1]
|
||||||
|
|
@ -769,14 +759,14 @@ proc main() =
|
||||||
skips = loadSkipFrom(skipFrom)
|
skips = loadSkipFrom(skipFrom)
|
||||||
for i, cati in cats:
|
for i, cati in cats:
|
||||||
progressStatus(i)
|
progressStatus(i)
|
||||||
processCategory(r, Category(cati), p.cmdLineRest.string, testsDir, runJoinableTests = false)
|
processCategory(r, Category(cati), p.cmdLineRest, testsDir, runJoinableTests = false)
|
||||||
else:
|
else:
|
||||||
addQuitProc azure.finalize
|
addExitProc azure.finalize
|
||||||
quit osproc.execProcesses(cmds, {poEchoCmd, poStdErrToStdOut, poUsePath, poParentStreams}, beforeRunEvent = progressStatus)
|
quit osproc.execProcesses(cmds, {poEchoCmd, poStdErrToStdOut, poUsePath, poParentStreams}, beforeRunEvent = progressStatus)
|
||||||
of "c", "cat", "category":
|
of "c", "cat", "category":
|
||||||
skips = loadSkipFrom(skipFrom)
|
skips = loadSkipFrom(skipFrom)
|
||||||
var cat = Category(p.key)
|
var cat = Category(p.key)
|
||||||
processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = true)
|
processCategory(r, cat, p.cmdLineRest, testsDir, runJoinableTests = true)
|
||||||
of "pcat":
|
of "pcat":
|
||||||
skips = loadSkipFrom(skipFrom)
|
skips = loadSkipFrom(skipFrom)
|
||||||
# 'pcat' is used for running a category in parallel. Currently the only
|
# 'pcat' is used for running a category in parallel. Currently the only
|
||||||
|
|
@ -785,12 +775,12 @@ proc main() =
|
||||||
isMainProcess = false
|
isMainProcess = false
|
||||||
var cat = Category(p.key)
|
var cat = Category(p.key)
|
||||||
p.next
|
p.next
|
||||||
processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = false)
|
processCategory(r, cat, p.cmdLineRest, testsDir, runJoinableTests = false)
|
||||||
of "p", "pat", "pattern":
|
of "p", "pat", "pattern":
|
||||||
skips = loadSkipFrom(skipFrom)
|
skips = loadSkipFrom(skipFrom)
|
||||||
let pattern = p.key
|
let pattern = p.key
|
||||||
p.next
|
p.next
|
||||||
processPattern(r, pattern, p.cmdLineRest.string, simulate)
|
processPattern(r, pattern, p.cmdLineRest, simulate)
|
||||||
of "r", "run":
|
of "r", "run":
|
||||||
var subPath = p.key
|
var subPath = p.key
|
||||||
let (cat, path) = splitTestFile(subPath)
|
let (cat, path) = splitTestFile(subPath)
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
discard """
|
|
||||||
output: "Hello World"
|
|
||||||
"""
|
|
||||||
|
|
||||||
const str = "Hello World"
|
|
||||||
echo str
|
|
||||||
|
|
||||||
# Splitters are done with this special comment:
|
|
||||||
|
|
||||||
#!EDIT!#
|
|
||||||
|
|
||||||
discard """
|
|
||||||
output: "Hello World B"
|
|
||||||
"""
|
|
||||||
|
|
||||||
const str = "Hello World"
|
|
||||||
echo str, " B"
|
|
||||||
|
|
||||||
#!EDIT!#
|
|
||||||
|
|
||||||
discard """
|
|
||||||
output: "Hello World C"
|
|
||||||
"""
|
|
||||||
|
|
||||||
const str = "Hello World"
|
|
||||||
var x = 7
|
|
||||||
if 3+4 == x:
|
|
||||||
echo str, " C"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue