diff options
-rw-r--r-- | testament/backend.nim | 9 | ||||
-rw-r--r-- | testament/categories.nim | 83 | ||||
-rw-r--r-- | testament/lib/stdtest/unittest_light.nim | 14 | ||||
-rw-r--r-- | testament/specs.nim | 38 | ||||
-rw-r--r-- | testament/testament.nim | 110 | ||||
-rw-r--r-- | tests/ic/thallo.nim | 28 |
6 files changed, 91 insertions, 191 deletions
diff --git a/testament/backend.nim b/testament/backend.nim index 0a6d7d8b9..c7d13be7e 100644 --- a/testament/backend.nim +++ b/testament/backend.nim @@ -13,7 +13,6 @@ type CommitId = distinct string proc `$`*(id: MachineId): string {.borrow.} -#proc `$`(id: CommitId): string {.borrow.} # not used var thisMachine: MachineId @@ -21,9 +20,9 @@ var thisBranch: string proc getMachine*(): MachineId = - var name = execProcess("hostname").string.strip + var name = execProcess("hostname").strip if name.len == 0: - name = when defined(posix): getEnv("HOSTNAME").string + name = when defined(posix): getEnv("HOSTNAME") else: getEnv("COMPUTERNAME").string if name.len == 0: quit "cannot determine the machine name" @@ -32,8 +31,8 @@ proc getMachine*(): MachineId = proc getCommit(): CommitId = const commLen = "commit ".len - let hash = execProcess("git log -n 1").string.strip[commLen..commLen+10] - thisBranch = execProcess("git symbolic-ref --short HEAD").string.strip + let hash = execProcess("git log -n 1").strip[commLen..commLen+10] + thisBranch = execProcess("git symbolic-ref --short HEAD").strip if hash.len == 0 or thisBranch.len == 0: quit "cannot determine git HEAD" result = CommitId(hash) diff --git a/testament/categories.nim b/testament/categories.nim index 39f0aaa27..4c6fa9c36 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -47,50 +47,6 @@ proc isTestFile*(file: string): bool = let (_, name, ext) = splitFile(file) 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 ------------------------------------------- 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!): const libpathenv = when defined(haiku): "LIBRARY_PATH" else: "LD_LIBRARY_PATH" - var libpath = getEnv(libpathenv).string + var libpath = getEnv(libpathenv) # Temporarily add the lib directory to LD_LIBRARY_PATH: putEnv(libpathenv, "tests/dll" & (if libpath.len > 0: ":" & libpath else: "")) defer: putEnv(libpathenv, libpath) @@ -265,7 +221,7 @@ proc debuggerTests(r: var TResults, cat: Category, options: string) = t.spec.action = actionCompile # force target to C because of MacOS 10.15 SDK headers bug # https://github.com/nim-lang/Nim/pull/15612#issuecomment-712471879 - t.spec.targets = { targetC } + t.spec.targets = {targetC} testSpec r, t # ------------------------- JS tests ------------------------------------------ @@ -384,7 +340,7 @@ proc findMainFile(dir: string): string = var nimFiles = 0 for kind, file in os.walkDir(dir): 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"): if result.len == 0: result = file inc nimFiles @@ -429,7 +385,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) = files.sort # reproducible order for testFile in files: - let contents = readFile(testFile).string + let contents = readFile(testFile) var testObj = makeTest(testFile, options, cat) #[ todo: @@ -445,7 +401,7 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) = # ----------------------------- nimble ---------------------------------------- -var nimbleDir = getEnv("NIMBLE_DIR").string +var nimbleDir = getEnv("NIMBLE_DIR") if nimbleDir.len == 0: nimbleDir = getHomeDir() / ".nimble" let nimbleExe = findExe("nimble") @@ -606,15 +562,6 @@ proc isJoinableSpec(spec: TSpec): bool = if spec.file.readFile.contains "when isMainModule": 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 = # todo: consider moving to system.nim result.addQuoted(a) @@ -632,8 +579,8 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = if isJoinableSpec(spec): specs.add spec - proc cmp(a: TSpec, b:TSpec): auto = cmp(a.file, b.file) - sort(specs, cmp=cmp) # reproducible order + proc cmp(a: TSpec, b: TSpec): auto = cmp(a.file, b.file) + sort(specs, cmp = cmp) # reproducible order echo "joinable specs: ", specs.len 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] var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "") if exitCode != 0: - echo "$ " & cmdLine & "\n" & buf.string + echo "$ " & cmdLine & "\n" & buf quit(failString & "megatest compilation failed") (buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).dup normalizeExe) if exitCode != 0: - echo buf.string + echo buf quit(failString & "megatest execution failed") const outputExceptedFile = "outputExpected.txt" const outputGottenFile = "outputGotten.txt" - writeFile(outputGottenFile, buf.string) + writeFile(outputGottenFile, buf) var outputExpected = "" for i, runSpec in specs: 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": outputExpected.add '\n' - if buf.string != outputExpected: + if buf != outputExpected: writeFile(outputExceptedFile, outputExpected) discard execShellCmd("diff -uNdr $1 $2" % [outputExceptedFile, outputGottenFile]) echo failString & "megatest output different!" @@ -690,10 +637,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = quit 1 else: 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, runJoinableTests: bool) = case cat.string.normalize - of "ic": - when false: - icTests(r, testsDir, cat, options) of "js": # only run the JS tests on Windows or Linux because Travis is bad # and other OSes like Haiku might lack nodejs: diff --git a/testament/lib/stdtest/unittest_light.nim b/testament/lib/stdtest/unittest_light.nim index bf254c11f..273bf72f5 100644 --- a/testament/lib/stdtest/unittest_light.nim +++ b/testament/lib/stdtest/unittest_light.nim @@ -11,26 +11,24 @@ proc mismatch*[T](lhs: T, rhs: T): string = proc quoted(s: string): string = result.addQuoted s - result.add "\n" + result.add '\n' result.add "lhs:{" & replaceInvisible( $lhs) & "}\nrhs:{" & replaceInvisible($rhs) & "}\n" when compiles(lhs.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]): var i = 0 while i < lhs.len and i < rhs.len: if lhs[i] != rhs[i]: break i.inc - result.add "first mismatch index: " & $i & "\n" + result.add "first mismatch index: " & $i & '\n' if i < lhs.len and i < rhs.len: result.add "lhs[i]: {" & quoted($lhs[i]) & "}\nrhs[i]: {" & quoted( $rhs[i]) & "}\n" result.add "lhs[0..<i]:{" & replaceInvisible($lhs[ - 0..<i]) & "}" + 0..<i]) & '}' proc assertEquals*[T](lhs: T, rhs: T, msg = "") = - when false: # can be useful for debugging to see all that's fed to this. - echo "----" & $lhs - if lhs!=rhs: - doAssert false, mismatch(lhs, rhs) & "\n" & msg + if lhs != rhs: + doAssert false, mismatch(lhs, rhs) & '\n' & msg diff --git a/testament/specs.nim b/testament/specs.nim index 48fe51658..d4c82e97e 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -34,27 +34,27 @@ type TOutputCheck* = enum ocIgnore = "ignore" - ocEqual = "equal" + ocEqual = "equal" ocSubstr = "substr" TResultEnum* = enum - reNimcCrash, # nim compiler seems to have crashed - reMsgsDiffer, # error messages differ - reFilesDiffer, # expected and given filenames differ - reLinesDiffer, # expected and given line numbers differ + reNimcCrash, # nim compiler seems to have crashed + reMsgsDiffer, # error messages differ + reFilesDiffer, # expected and given filenames differ + reLinesDiffer, # expected and given line numbers differ reOutputsDiffer, - reExitcodesDiffer, # exit codes of program or of valgrind differ + reExitcodesDiffer, # exit codes of program or of valgrind differ reTimeout, reInvalidPeg, reCodegenFailure, reCodeNotFound, reExeNotFound, - reInstallFailed # package installation failed - reBuildFailed # package building failed - reDisabled, # test is disabled - reJoined, # test is disabled because it was joined into the megatest - reSuccess # test was successful - reInvalidSpec # test had problems to parse the spec + reInstallFailed # package installation failed + reBuildFailed # package building failed + reDisabled, # test is disabled + reJoined, # test is disabled because it was joined into the megatest + reSuccess # test was successful + reInvalidSpec # test had problems to parse the spec TTarget* = enum targetC = "c" @@ -69,7 +69,7 @@ type ValgrindSpec* = enum disabled, enabled, leaking - + TSpec* = object # xxx make sure `isJoinableSpec` takes into account each field here. action*: TTestAction @@ -90,7 +90,7 @@ type targets*: set[TTarget] matrix*: seq[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 unbatchable*: bool # whether this test can be batchable via `NIM_TESTAMENT_BATCH`; only very @@ -98,7 +98,7 @@ type # by making the dependencies explicit useValgrind*: ValgrindSpec 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 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 = const tripleQuote = "\"\"\"" - var s = readFile(filename).string + var s = readFile(filename) var i = 0 var a = -1 @@ -225,7 +225,7 @@ proc addLine*(self: var string; a: string) = self.add a self.add "\n" -proc addLine*(self: var string; a,b: string) = +proc addLine*(self: var string; a, b: string) = self.add a self.add b self.add "\n" @@ -233,7 +233,7 @@ proc addLine*(self: var string; a,b: string) = proc initSpec*(filename: string): TSpec = result.file = filename -proc isCurrentBatch(testamentData: TestamentData, filename: string): bool = +proc isCurrentBatch(testamentData: TestamentData; filename: string): bool = if testamentData.testamentNumBatch != 0: hash(filename) mod testamentData.testamentNumBatch == testamentData.testamentBatch else: @@ -297,7 +297,7 @@ proc parseSpec*(filename: string): TSpec = result.output = strip(e.value) of "sortoutput": try: - result.sortoutput = parseCfgBool(e.value) + result.sortoutput = parseCfgBool(e.value) except: result.parseErrors.addLine getCurrentExceptionMsg() of "exitcode": diff --git a/testament/testament.nim b/testament/testament.nim index 3ffd6907c..9d3e9e702 100644 --- a/testament/testament.nim +++ b/testament/testament.nim @@ -10,9 +10,9 @@ ## This program verifies Nim against the testcases. import - strutils, pegs, os, osproc, streams, json, + strutils, pegs, os, osproc, streams, json, std/exitprocs, backend, parseopt, specs, htmlgen, browsers, terminal, - algorithm, times, md5, sequtils, azure, intsets + algorithm, times, md5, sequtils, azure, intsets, macros from std/sugar import dup import compiler/nodejs import lib/stdtest/testutils @@ -26,7 +26,6 @@ const failString* = "FAIL: " # ensures all failures can be searched with 1 keyword in CI logs testsDir = "tests" & DirSep resultsFile = "testresults.html" - #jsonFile = "testresults.json" # not used Usage = """Usage: 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 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 = result = filename.splitFile().dir if not result.isAbsolute(): @@ -111,8 +103,8 @@ proc execCmdEx2(command: string, args: openArray[string]; workingDir, input: str for arg in args: result.cmdLine.add ' ' result.cmdLine.add quoteShell(arg) - var p = startProcess(command, workingDir=workingDir, args=args, - options={poStdErrToStdOut, poUsePath}) + var p = startProcess(command, workingDir = workingDir, args = args, + options = {poStdErrToStdOut, poUsePath}) var outp = outputStream(p) # 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) close instream - result.exitCode = -1 + result.exitCode = -1 var line = newStringOfCap(120) while true: if outp.readLine(line): - result.output.string.add(line.string) - result.output.string.add("\n") + result.output.add line + result.output.add '\n' else: result.exitCode = peekExitCode(p) if result.exitCode != -1: break @@ -140,10 +132,10 @@ proc nimcacheDir(filename, options: string, target: TTarget): string = proc prepareTestArgs(cmdTemplate, filename, options, nimcache: 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 - if nimcache.len > 0: options.add " " & ("--nimCache:" & nimcache).quoteShell - options.add " " & extraOptions + if nimcache.len > 0: options.add ' ' & ("--nimCache:" & nimcache).quoteShell + options.add ' ' & extraOptions result = parseCmdLine(cmdTemplate % ["target", targetToCmd[target], "options", options, "file", filename.quoteShell, "filedir", filename.getFileDir(), "nim", compilerPrefix]) @@ -153,8 +145,8 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string, let c = prepareTestArgs(cmdTemplate, filename, options, nimcache, target, extraOptions) result.cmd = quoteShellCommand(c) - var p = startProcess(command=c[0], args=c[1 .. ^1], - options={poStdErrToStdOut, poUsePath}) + var p = startProcess(command = c[0], args = c[1 .. ^1], + options = {poStdErrToStdOut, poUsePath}) let outp = p.outputStream var suc = "" var err = "" @@ -163,7 +155,7 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string, result.nimout = "" while true: if outp.readLine(x): - result.nimout.add(x & "\n") + result.nimout.add(x & '\n') if x =~ pegOfInterest: # `err` should contain the last error/warning message err = x @@ -201,8 +193,8 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string, proc callCCompiler(cmdTemplate, filename, options: string, target: TTarget): TSpec = let c = prepareTestArgs(cmdTemplate, filename, options, nimcache = "", target) - var p = startProcess(command="gcc", args=c[5 .. ^1], - options={poStdErrToStdOut, poUsePath}) + var p = startProcess(command = "gcc", args = c[5 .. ^1], + options = {poStdErrToStdOut, poUsePath}) let outp = p.outputStream var x = newStringOfCap(120) result.nimout = "" @@ -212,7 +204,7 @@ proc callCCompiler(cmdTemplate, filename, options: string, result.line = -1 while true: if outp.readLine(x): - result.nimout.add(x & "\n") + result.nimout.add(x & '\n') elif not running(p): break close(p) @@ -225,8 +217,6 @@ proc initResults: TResults = result.skipped = 0 result.data = "" -import macros - macro ignoreStyleEcho(args: varargs[typed]): untyped = let typForegroundColor = bindSym"ForegroundColor".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 # A bit hacky but simple and works with tests/testament/tshould_not_work.nim var name = test.name.replace(DirSep, '/') - name.add " " & $target - if test.options.len > 0: name.add " " & test.options + name.add ' ' & $target + if test.options.len > 0: name.add ' ' & test.options let duration = epochTime() - test.startTime 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) r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success) template disp(msg) = - maybeStyledEcho styleDim, fgYellow, msg & " ", styleBright, fgCyan, name + maybeStyledEcho styleDim, fgYellow, msg & ' ', styleBright, fgCyan, name if success == reSuccess: maybeStyledEcho fgGreen, "PASS: ", fgCyan, alignLeft(name, 60), fgBlue, " (", durationStr, " sec)" elif success == reDisabled: @@ -307,18 +297,18 @@ proc addResult(r: var TResults, test: TTest, target: TTarget, of reDisabled, reJoined: ("Skipped", "") of reBuildFailed, reNimcCrash, reInstallFailed: - ("Failed", "Failure: " & $success & "\n" & given) + ("Failed", "Failure: " & $success & '\n' & given) else: ("Failed", "Failure: " & $success & "\nExpected:\n" & expected & "\n\n" & "Gotten:\n" & given) 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, + 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}) + "-Duration", $(duration * 1000).int], + options = {poStdErrToStdOut, poUsePath, poParentStreams}) discard waitForExit(p) close(p) @@ -346,7 +336,7 @@ proc checkForInlineErrors(r: var TResults, expected, given: TSpec, test: TTest, for j in 0..high(expected.inlineErrors): if j notin covered: var e = test.name - e.add "(" + e.add '(' e.addInt expected.inlineErrors[j].line if expected.inlineErrors[j].col > 0: e.add ", " @@ -404,7 +394,7 @@ proc codegenCheck(test: TTest, target: TTarget, spec: TSpec, expectedMsg: var st given: var TSpec) = try: let genFile = generatedFile(test, target) - let contents = readFile(genFile).string + let contents = readFile(genFile) for check in spec.ccodeCheck: if check.len > 0 and check[0] == '\\': # little hack to get 'match' support: @@ -441,12 +431,12 @@ proc compilerOutputTests(test: TTest, target: TTarget, given: var TSpec, givenmsg = given.nimout.strip nimoutCheck(test, expectedmsg, given) else: - givenmsg = "$ " & given.cmd & "\n" & given.nimout + givenmsg = "$ " & given.cmd & '\n' & given.nimout if given.err == reSuccess: inc(r.passed) r.addResult(test, target, expectedmsg, givenmsg, given.err) proc getTestSpecTarget(): TTarget = - if getEnv("NIM_COMPILE_TO_CPP", "false").string == "true": + if getEnv("NIM_COMPILE_TO_CPP", "false") == "true": result = targetCpp else: 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, nimcache, target, extraOptions) 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: let isJsTarget = target == targetJS 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 let bufB = if expected.sortoutput: - var buf2 = buf.string + var buf2 = buf buf2.stripLineEnd var x = splitLines(buf2) sort(x, system.cmp) - join(x, "\n") & "\n" + join(x, "\n") & '\n' else: - buf.string + buf if exitCode != expected.exitCode: r.addResult(test, target, "exitcode: " & $expected.exitCode, "exitcode: " & $exitCode & "\n\nOutput:\n" & @@ -566,7 +556,7 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) = else: 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 for target in test.spec.targets: inc(r.total) @@ -600,7 +590,7 @@ proc testExec(r: var TResults, test: TTest) = given.err = reSuccess else: given.err = reExitcodesDiffer - given.msg = outp.string + given.msg = outp if given.err == reSuccess: inc(r.passed) 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.startTime = epochTime() -proc makeRawTest(test, options: string, cat: Category): TTest = +proc makeRawTest(test, options: string, cat: Category): TTest {.used.} = result.cat = cat result.name = test result.options = options @@ -659,7 +649,7 @@ proc loadSkipFrom(name: string): seq[string] = # used by `nlvm` (at least) for line in lines(name): let sline = line.strip() - if sline.len > 0 and not sline.startsWith("#"): + if sline.len > 0 and not sline.startsWith('#'): result.add sline proc main() = @@ -675,20 +665,20 @@ proc main() = var p = initOptParser() p.next() while p.kind in {cmdLongOption, cmdShortOption}: - case p.key.string.normalize + case p.key.normalize of "print", "verbose": optPrintResults = true of "failing": optFailing = true of "pedantic": discard "now always enabled" of "targets": - targetsStr = p.val.string + targetsStr = p.val gTargets = parseTargets(targetsStr) targetsSet = true of "nim": - compilerPrefix = addFileExt(p.val.string.absolutePath, ExeExt) + compilerPrefix = addFileExt(p.val.absolutePath, ExeExt) of "directory": - setCurrentDir(p.val.string) + setCurrentDir(p.val) of "colors": - case p.val.string: + case p.val: of "on": useColors = true of "off": @@ -707,7 +697,7 @@ proc main() = of "simulate": simulate = true of "megatest": - case p.val.string: + case p.val: of "on": useMegatest = true of "off": @@ -715,7 +705,7 @@ proc main() = else: quit Usage of "backendlogging": - case p.val.string: + case p.val: of "on": backendLogging = true of "off": @@ -723,13 +713,13 @@ proc main() = else: quit Usage of "skipfrom": - skipFrom = p.val.string + skipFrom = p.val else: quit Usage p.next() if p.kind != cmdArgument: quit Usage - var action = p.key.string.normalize + var action = p.key.normalize p.next() var r = initResults() case action @@ -748,7 +738,7 @@ proc main() = myself &= " " & quoteShell("--skipFrom:" & skipFrom) 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): assert testsDir.startsWith(testsDir) let cat = dir[testsDir.len .. ^1] @@ -769,14 +759,14 @@ proc main() = skips = loadSkipFrom(skipFrom) for i, cati in cats: progressStatus(i) - processCategory(r, Category(cati), p.cmdLineRest.string, testsDir, runJoinableTests = false) + processCategory(r, Category(cati), p.cmdLineRest, testsDir, runJoinableTests = false) else: - addQuitProc azure.finalize + addExitProc azure.finalize quit osproc.execProcesses(cmds, {poEchoCmd, poStdErrToStdOut, poUsePath, poParentStreams}, beforeRunEvent = progressStatus) of "c", "cat", "category": skips = loadSkipFrom(skipFrom) var cat = Category(p.key) - processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = true) + processCategory(r, cat, p.cmdLineRest, testsDir, runJoinableTests = true) of "pcat": skips = loadSkipFrom(skipFrom) # 'pcat' is used for running a category in parallel. Currently the only @@ -785,12 +775,12 @@ proc main() = isMainProcess = false var cat = Category(p.key) p.next - processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = false) + processCategory(r, cat, p.cmdLineRest, testsDir, runJoinableTests = false) of "p", "pat", "pattern": skips = loadSkipFrom(skipFrom) let pattern = p.key p.next - processPattern(r, pattern, p.cmdLineRest.string, simulate) + processPattern(r, pattern, p.cmdLineRest, simulate) of "r", "run": var subPath = p.key let (cat, path) = splitTestFile(subPath) diff --git a/tests/ic/thallo.nim b/tests/ic/thallo.nim deleted file mode 100644 index 7ead7c8ba..000000000 --- a/tests/ic/thallo.nim +++ /dev/null @@ -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" |