summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJacek Sieka <arnetheduck@gmail.com>2019-04-23 14:09:41 -0600
committerAndreas Rumpf <rumpf_a@web.de>2019-04-23 22:09:41 +0200
commit3c689c1f2e41b1e355fd62722c542a61db1f5b48 (patch)
treeadddf2b64f38096321c4f385ccc514e6a7ae1abb
parent02920c2cd932a28cca7f38e149844e55ca5c5f56 (diff)
downloadNim-3c689c1f2e41b1e355fd62722c542a61db1f5b48.tar.gz
tester: add test skipping capability (#11080)
-rw-r--r--testament/categories.nim20
-rw-r--r--testament/tester.nim13
2 files changed, 29 insertions, 4 deletions
diff --git a/testament/categories.nim b/testament/categories.nim
index add080020..a2ce8a094 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -11,6 +11,7 @@
 ## of the compiler.
 
 import important_packages
+import sequtils
 
 const
   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) =
+  let skips = loadSkipFrom(skipFrom)
+
   case cat.string.normalize
   of "rodfiles":
     when false:
@@ -745,6 +760,9 @@ proc processCategory(r: var TResults, cat: Category, options, testsDir: string,
 
     for i, name in files:
       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:
         discard "run the test"
       else:
diff --git a/testament/tester.nim b/testament/tester.nim
index 5b1d327c8..fb8ba1838 100644
--- a/testament/tester.nim
+++ b/testament/tester.nim
@@ -48,6 +48,7 @@ Options:
   --directory:dir           Change to directory dir before reading the tests or doing anything else.
   --colors:on|off           Turn messagescoloring on|off.
   --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
 
 type
@@ -545,6 +546,7 @@ proc main() =
   var optFailing = false
   var targetsStr = ""
   var isMainProcess = true
+  var skipFrom = ""
 
   var p = initOptParser()
   p.next()
@@ -580,6 +582,8 @@ proc main() =
         backendLogging = false
       else:
         quit Usage
+    of "skipfrom":
+      skipFrom = p.val.string
     else:
       quit Usage
     p.next()
@@ -598,6 +602,9 @@ proc main() =
 
     myself &= " " & quoteShell("--nim:" & compilerPrefix)
 
+    if skipFrom.len > 0:
+      myself &= " " & quoteShell("--skipFrom:" & skipFrom)
+
     var cats: seq[string]
     let rest = if p.cmdLineRest.string.len > 0: " " & p.cmdLineRest.string else: ""
     for kind, dir in walkDir(testsDir):
@@ -617,13 +624,13 @@ proc main() =
     if simulate:
       for i, cati in cats:
         progressStatus(i)
-        processCategory(r, Category(cati), p.cmdLineRest.string, testsDir, runJoinableTests = false)
+        processCategory(r, Category(cati), p.cmdLineRest.string, testsDir, skipFrom, runJoinableTests = false)
     else:
       quit osproc.execProcesses(cmds, {poEchoCmd, poStdErrToStdOut, poUsePath, poParentStreams}, beforeRunEvent = progressStatus)
   of "c", "cat", "category":
     var cat = Category(p.key)
     p.next
-    processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = true)
+    processCategory(r, cat, p.cmdLineRest.string, testsDir, skipFrom, runJoinableTests = true)
   of "pcat":
     # '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
@@ -631,7 +638,7 @@ 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.string, testsDir, skipFrom, runJoinableTests = false)
   of "r", "run":
     # at least one directory is required in the path, to use as a category name
     let pathParts = split(p.key.string, {DirSep, AltSep})