summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-10-24 19:02:34 +0200
committerGitHub <noreply@github.com>2016-10-24 19:02:34 +0200
commit56181da2045ed0ec5d67868cfd428c1b5c26455c (patch)
treea0b39e7463ee800c52e9278610f688e255ecb1fa
parent00f09f1309f9ee4273a944ff0a5baad963ce0cc8 (diff)
parent248b5c0468bc0fbbf2f4963b7980a64ed3060c43 (diff)
downloadNim-56181da2045ed0ec5d67868cfd428c1b5c26455c.tar.gz
Merge pull request #4800 from Wh1teDuke/FixTesterRunOpt
[Tester] allow running single tests with 'run' option
-rw-r--r--tests/testament/categories.nim10
-rw-r--r--tests/testament/tester.nim2
2 files changed, 9 insertions, 3 deletions
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 2b0b55c0b..809425653 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -382,8 +382,14 @@ proc `&.?`(a, b: string): string =
 proc `&?.`(a, b: string): string =
   # candidate for the stdlib?
   result = if a.endswith(b): a else: a & b
+  
+proc processSingleTest(r: var TResults, cat: Category, options, test: string) =
+  let test = "tests" & DirSep &.? cat.string / test
 
-proc processCategory(r: var TResults, cat: Category, options: string, fileGlob: string = "t*.nim") =
+  if existsFile(test): testSpec r, makeTest(test, options, cat)
+  else: echo "[Warning] - ", test, " test does not exist"
+
+proc processCategory(r: var TResults, cat: Category, options: string) =
   case cat.string.normalize
   of "rodfiles":
     when false: compileRodFiles(r, cat, options)
@@ -424,5 +430,5 @@ proc processCategory(r: var TResults, cat: Category, options: string, fileGlob:
     # We can't test it because it depends on a third party.
     discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.
   else:
-    for name in os.walkFiles("tests" & DirSep &.? cat.string / fileGlob):
+    for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
       testSpec r, makeTest(name, options, cat)
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 74ac58927..2734742f4 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -445,7 +445,7 @@ proc main() =
     let (dir, file) = splitPath(p.key.string)
     let (_, subdir) = splitPath(dir)
     var cat = Category(subdir)
-    processCategory(r, cat, p.cmdLineRest.string, file)
+    processSingleTest(r, cat, p.cmdLineRest.string, file)
   of "html":
     var commit = 0
     discard parseInt(p.cmdLineRest.string, commit)