summary refs log tree commit diff stats
path: root/testament
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-08-30 15:43:07 +0200
committerGitHub <noreply@github.com>2019-08-30 15:43:07 +0200
commit82d5e773e3cccbca6632ff7cbfcec055ab4b915b (patch)
treefe28708722399390b0bb2e62f94e9a30d194c479 /testament
parent25581c796f519cb41d8b40b48bf160678339b87f (diff)
downloadNim-82d5e773e3cccbca6632ff7cbfcec055ab4b915b.tar.gz
make testament a tool we ship with Nim; fixes #12084 (#12088)
* make testament a tool we ship with Nim; fixes #12084
* moved config to fit
* adapt testament tests to use the testament binary
Diffstat (limited to 'testament')
-rw-r--r--testament/categories.nim12
-rw-r--r--testament/testament.nim (renamed from testament/tester.nim)18
-rw-r--r--testament/testament.nim.cfg (renamed from testament/tester.nim.cfg)0
3 files changed, 26 insertions, 4 deletions
diff --git a/testament/categories.nim b/testament/categories.nim
index 745abebe3..d5cf79e3a 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -717,3 +717,15 @@ proc processCategory(r: var TResults, cat: Category,
       inc testsRun
     if testsRun == 0:
       echo "[Warning] - Invalid category specified \"", cat.string, "\", no tests were run"
+
+proc processPattern(r: var TResults, pattern, options: string; simulate: bool) =
+  var testsRun = 0
+  for name in walkPattern(pattern):
+    if simulate:
+      echo "Detected test: ", name
+    else:
+      var test = makeTest(name, options, Category"pattern")
+      testSpec r, test
+    inc testsRun
+  if testsRun == 0:
+    echo "no tests were found for pattern: ", pattern
diff --git a/testament/tester.nim b/testament/testament.nim
index c32228ca8..5d0213ce5 100644
--- a/testament/tester.nim
+++ b/testament/testament.nim
@@ -1,6 +1,6 @@
 #
 #
-#            Nim Tester
+#            Nim Testament
 #        (c) Copyright 2017 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -25,9 +25,10 @@ const
   resultsFile = "testresults.html"
   #jsonFile = "testresults.json" # not used
   Usage = """Usage:
-  tester [options] command [arguments]
+  testament [options] command [arguments]
 
 Command:
+  p|pat|pattern <glob>        run all the tests matching the given pattern
   all                         run all tests
   c|cat|category <category>   run all the tests of a certain category
   r|run <test>                run single test file
@@ -435,6 +436,10 @@ proc testSpecHelper(r: var TResults, test: TTest, expected: TSpec, target: TTarg
           if isJsTarget:
             exeCmd = nodejs
             args = concat(@[exeFile], args)
+          elif defined(posix) and not exeFile.contains('/'):
+            # "security" in Posix is actually just a euphemism
+            # for "unproductive arbitrary shit"
+            exeCmd = "./" & exeFile
           else:
             exeCmd = exeFile
           var (_, buf, exitCode) = execCmdEx2(exeCmd, args, input = expected.input)
@@ -594,7 +599,7 @@ proc main() =
 
   var p = initOptParser()
   p.next()
-  while p.kind == cmdLongoption:
+  while p.kind in {cmdLongoption, cmdShortOption}:
     case p.key.string.normalize
     of "print", "verbose": optPrintResults = true
     of "failing": optFailing = true
@@ -646,7 +651,7 @@ proc main() =
   of "all":
     #processCategory(r, Category"megatest", p.cmdLineRest.string, testsDir, runJoinableTests = false)
 
-    var myself = quoteShell(findExe("testament" / "tester"))
+    var myself = quoteShell(findExe("testament" / "testament"))
     if targetsStr.len > 0:
       myself &= " " & quoteShell("--targets:" & targetsStr)
 
@@ -694,6 +699,11 @@ proc main() =
     var cat = Category(p.key)
     p.next
     processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = false)
+  of "p", "pat", "pattern":
+    skips = loadSkipFrom(skipFrom)
+    let pattern = p.key
+    p.next
+    processPattern(r, pattern, p.cmdLineRest.string, simulate)
   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})
diff --git a/testament/tester.nim.cfg b/testament/testament.nim.cfg
index 27fd67075..27fd67075 100644
--- a/testament/tester.nim.cfg
+++ b/testament/testament.nim.cfg