tester: add test skipping capability (#11080)
This commit is contained in:
parent
02920c2cd9
commit
3c689c1f2e
2 changed files with 29 additions and 4 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
## of the compiler.
|
## of the compiler.
|
||||||
|
|
||||||
import important_packages
|
import important_packages
|
||||||
|
import sequtils
|
||||||
|
|
||||||
const
|
const
|
||||||
specialCategories = [
|
specialCategories = [
|
||||||
|
|
@ -688,8 +689,22 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
proc processCategory(r: var TResults, cat: Category, options, testsDir: string,
|
proc loadSkipFrom(name: string): seq[string] =
|
||||||
|
# One skip per line, comments start with #
|
||||||
|
# used by `nlvm` (at least)
|
||||||
|
try:
|
||||||
|
for line in lines(name):
|
||||||
|
let sline = line.strip()
|
||||||
|
if sline.len > 0 and not sline.startsWith("#"):
|
||||||
|
result.add sline
|
||||||
|
except:
|
||||||
|
echo "Could not load " & name & ", ignoring"
|
||||||
|
|
||||||
|
proc processCategory(r: var TResults, cat: Category,
|
||||||
|
options, testsDir, skipFrom: string,
|
||||||
runJoinableTests: bool) =
|
runJoinableTests: bool) =
|
||||||
|
let skips = loadSkipFrom(skipFrom)
|
||||||
|
|
||||||
case cat.string.normalize
|
case cat.string.normalize
|
||||||
of "rodfiles":
|
of "rodfiles":
|
||||||
when false:
|
when false:
|
||||||
|
|
@ -745,6 +760,9 @@ proc processCategory(r: var TResults, cat: Category, options, testsDir: string,
|
||||||
|
|
||||||
for i, name in files:
|
for i, name in files:
|
||||||
var test = makeTest(name, options, cat)
|
var test = makeTest(name, options, cat)
|
||||||
|
if skips.anyIt(it in name):
|
||||||
|
test.spec.err = reDisabled
|
||||||
|
|
||||||
if runJoinableTests or not isJoinableSpec(test.spec) or cat.string in specialCategories:
|
if runJoinableTests or not isJoinableSpec(test.spec) or cat.string in specialCategories:
|
||||||
discard "run the test"
|
discard "run the test"
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ Options:
|
||||||
--directory:dir Change to directory dir before reading the tests or doing anything else.
|
--directory:dir Change to directory dir before reading the tests or doing anything else.
|
||||||
--colors:on|off Turn messagescoloring on|off.
|
--colors:on|off Turn messagescoloring on|off.
|
||||||
--backendLogging:on|off Disable or enable backend logging. By default turned on.
|
--backendLogging:on|off Disable or enable backend logging. By default turned on.
|
||||||
|
--skipFrom:file Read tests to skip from `file` - one test per line, # comments ignored
|
||||||
""" % resultsFile
|
""" % resultsFile
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -545,6 +546,7 @@ proc main() =
|
||||||
var optFailing = false
|
var optFailing = false
|
||||||
var targetsStr = ""
|
var targetsStr = ""
|
||||||
var isMainProcess = true
|
var isMainProcess = true
|
||||||
|
var skipFrom = ""
|
||||||
|
|
||||||
var p = initOptParser()
|
var p = initOptParser()
|
||||||
p.next()
|
p.next()
|
||||||
|
|
@ -580,6 +582,8 @@ proc main() =
|
||||||
backendLogging = false
|
backendLogging = false
|
||||||
else:
|
else:
|
||||||
quit Usage
|
quit Usage
|
||||||
|
of "skipfrom":
|
||||||
|
skipFrom = p.val.string
|
||||||
else:
|
else:
|
||||||
quit Usage
|
quit Usage
|
||||||
p.next()
|
p.next()
|
||||||
|
|
@ -598,6 +602,9 @@ proc main() =
|
||||||
|
|
||||||
myself &= " " & quoteShell("--nim:" & compilerPrefix)
|
myself &= " " & quoteShell("--nim:" & compilerPrefix)
|
||||||
|
|
||||||
|
if skipFrom.len > 0:
|
||||||
|
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.string.len > 0: " " & p.cmdLineRest.string else: ""
|
||||||
for kind, dir in walkDir(testsDir):
|
for kind, dir in walkDir(testsDir):
|
||||||
|
|
@ -617,13 +624,13 @@ proc main() =
|
||||||
if simulate:
|
if simulate:
|
||||||
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.string, testsDir, skipFrom, runJoinableTests = false)
|
||||||
else:
|
else:
|
||||||
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":
|
||||||
var cat = Category(p.key)
|
var cat = Category(p.key)
|
||||||
p.next
|
p.next
|
||||||
processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = true)
|
processCategory(r, cat, p.cmdLineRest.string, testsDir, skipFrom, runJoinableTests = true)
|
||||||
of "pcat":
|
of "pcat":
|
||||||
# 'pcat' is used for running a category in parallel. Currently the only
|
# '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
|
# difference is that we don't want to run joinable tests here as they
|
||||||
|
|
@ -631,7 +638,7 @@ 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.string, testsDir, skipFrom, runJoinableTests = false)
|
||||||
of "r", "run":
|
of "r", "run":
|
||||||
# at least one directory is required in the path, to use as a category name
|
# at least one directory is required in the path, to use as a category name
|
||||||
let pathParts = split(p.key.string, {DirSep, AltSep})
|
let pathParts = split(p.key.string, {DirSep, AltSep})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue