summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ccgstmts.nim3
-rw-r--r--testament/categories.nim113
-rw-r--r--testament/specs.nim1
-rw-r--r--testament/tester.nim5
-rw-r--r--tests/array/tarray.nim2
-rw-r--r--tests/async/tasyncfile.nim3
-rw-r--r--tests/ccgbugs/tconstobj.nim16
-rw-r--r--tests/collections/thashsets.nim (renamed from tests/collections/tsets.nim)0
-rw-r--r--tests/compilerapi/tcompilerapi.nim3
-rw-r--r--tests/concepts/trandomvars2.nim (renamed from tests/concepts/trandom_vars.nim)0
-rw-r--r--tests/iter/titerconcat.nim (renamed from tests/iter/tconcat.nim)0
-rw-r--r--tests/macros/tmacrogensym.nim (renamed from tests/macros/tgensym.nim)0
-rw-r--r--tests/metatype/tmeta_typeclasses.nim (renamed from tests/metatype/ttypeclasses.nim)0
-rw-r--r--tests/metatype/tmetatypematrix.nim (renamed from tests/metatype/tmatrix.nim)0
-rw-r--r--tests/misc/tradix.nim100
-rw-r--r--tests/stdlib/tsqlparser.nim2
-rw-r--r--tests/stdlib/tstdlib_various.nim2
-rw-r--r--tests/system/tostring.nim5
-rw-r--r--tests/types/tissues_types.nim (renamed from tests/types/tissues.nim)0
-rw-r--r--tests/vm/tconstobj.nim22
-rw-r--r--tests/vm/tmitems_vm.nim (renamed from tests/vm/tmitems.nim)0
-rw-r--r--tests/vm/tvmmisc.nim3
22 files changed, 150 insertions, 130 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim
index e83b80b7c..6c33b302d 100644
--- a/compiler/ccgstmts.nim
+++ b/compiler/ccgstmts.nim
@@ -559,7 +559,8 @@ proc genParForStmt(p: BProc, t: PNode) =
     initLocExpr(p, call.sons[1], rangeA)
     initLocExpr(p, call.sons[2], rangeB)
 
-    lineF(p, cpsStmts, "#pragma omp $4$n" &
+    # $n at the beginning because of #9710
+    lineF(p, cpsStmts, "$n#pragma omp $4$n" &
                         "for ($1 = $2; $1 <= $3; ++$1)",
                         [forLoopVar.loc.rdLoc,
                         rangeA.rdLoc, rangeB.rdLoc,
diff --git a/testament/categories.nim b/testament/categories.nim
index 6ab14a2cf..8bb89c0ae 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -553,3 +553,116 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
       inc testsRun
     if testsRun == 0:
       echo "[Warning] - Invalid category specified \"", cat.string, "\", no tests were run"
+
+
+const specialCategories = [
+  "async",
+  "debugger",
+  "dll",
+  "examples",
+  "flags",
+  "gc",
+  "io",
+  "js",
+  "lib",
+  "longgc",
+  "manyloc",
+  "nimble-all",
+  "nimble-core",
+  "nimble-extra",
+  "niminaction",
+  "rodfiles",
+  "threads",
+  "untestable"
+]
+
+
+# these tests still have bugs. At some point when the bugs are fixd
+# this should become empty.
+
+# exclude for various reasons
+const specialDisabedTests = [
+  "tests/dir with space/tspace.nim", # can't import dir with spaces.
+  "tests/method/tmultim.nim",        # (77, 8) Error: method is not a base
+  "tests/system/talloc2.nim",        # too much memory
+  "tests/collections/ttables.nim",   # takes too long
+  "tests/system/tparams.nim",        # executes itself with parameters
+  "tests/stdlib/tquit.nim",          # not testing for obvious reasons
+  "tests/system/trealloc.nim",       # out of memory
+  "tests/system/t7894.nim",          # causes out of memory in later tests
+  "tests/types/tissues_types.nim",   # causes out of memory with --gc:boehm
+]
+
+proc parseAllSpecs(): void =
+  var specs: array[TTestAction, seq[TSpec]]
+  var specialTests = 0
+  var ignoredTests = 0
+  var specsWithCfg: seq[TSpec]
+  var specsWithCustomCmd: seq[TSpec]
+  var specsEarlyExit: seq[TSpec]
+  var specsWithInput: seq[TSpec]
+
+  for file in os.walkFiles("tests/*/t*.nim"):
+
+    let a = find(file, '/') + 1
+    let b = find(file, '/', a)
+    let cat = file[a ..< b]
+
+    if cat in specialCategories:
+      specialTests += 1
+      continue
+
+    if file in specialDisabedTests:
+      # a special ignore here.
+      continue
+
+    let spec = parseSpec(file)
+
+    #echo cat, ": ", file
+    if fileExists(file & ".cfg"):
+      specsWithCfg.add spec
+      continue
+
+    if fileExists(parentDir(file) / "nim.cfg"):
+      specsWithCfg.add spec
+      continue
+
+    if spec.cmd != cmdTemplate():
+      specsWithCustomCmd.add spec
+      continue
+
+    if spec.err == reIgnored:
+      ignoredTests += 1
+      continue
+
+    if spec.exitCode != 0:
+      specsEarlyExit.add spec
+      continue
+
+    if spec.input != "":
+      specsWithInput.add spec
+      continue
+
+    specs[spec.action].add spec
+
+  for action, specs in specs.pairs:
+    echo action, ": ", specs.len
+  echo "specsWithCfg: ", specsWithCfg.len
+  echo "specsWithCustomCmd: ", specsWithCustomCmd.len
+  echo "earlyExit: ", specsEarlyExit.len
+  echo "special: ", specialTests
+  echo "ignored: ", ignoredTests
+  echo "withInput: ", specsWithInput.len
+
+  var megatest: string
+
+  for runSpec in specs[actionRun]:
+    if targetC in runSpec.targets or runSpec.targets == {}:
+      megatest.add "echo \"------------------------------: "
+      megatest.add runSpec.file
+      megatest.add "\"\n"
+      megatest.add "import \""
+      megatest.add runSpec.file
+      megatest.add "\"\n"
+
+  writeFile("megatest.nim", megatest)
diff --git a/testament/specs.nim b/testament/specs.nim
index 6c9fafa13..e3bc12376 100644
--- a/testament/specs.nim
+++ b/testament/specs.nim
@@ -22,7 +22,6 @@ type
     actionRun = "run"
     actionCompile = "compile"
     actionReject = "reject"
-    actionRunNoSpec = "runNoSpec"
 
   TOutputCheck* = enum
     ocIgnore = "ignore"
diff --git a/testament/tester.nim b/testament/tester.nim
index 7dfcf9d48..0d736fb3e 100644
--- a/testament/tester.nim
+++ b/testament/tester.nim
@@ -28,6 +28,7 @@ Command:
   c|cat|category <category>   run all the tests of a certain category
   r|run <test>                run single test file
   html                        generate $1 from the database
+  stats                       generate statistics about test cases
 Arguments:
   arguments are passed to the compiler
 Options:
@@ -380,7 +381,7 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
       var given = callCompiler(expected.cmd, test.name, test.options, target,
         extraOptions=" --stdout --hint[Path]:off --hint[Processing]:off")
       compilerOutputTests(test, target, given, expected, r)
-    of actionRun, actionRunNoSpec:
+    of actionRun:
       # In this branch of code "early return" pattern is clearer than deep
       # nested conditionals - the empty rows in between to clarify the "danger"
       var given = callCompiler(expected.cmd, test.name, test.options,
@@ -580,6 +581,8 @@ proc main() =
     processSingleTest(r, cat, p.cmdLineRest.string, file)
   of "html":
     generateHtml(resultsFile, optFailing)
+  of "stats":
+    parseAllSpecs()
   else:
     quit Usage
 
diff --git a/tests/array/tarray.nim b/tests/array/tarray.nim
index d12808668..96e90c97a 100644
--- a/tests/array/tarray.nim
+++ b/tests/array/tarray.nim
@@ -356,7 +356,7 @@ block troofregression:
   echo testStr[testStr.len - 8 .. testStr.len - 1] & "__" & testStr[0 .. testStr.len - pred(rot)]
 
   var
-    instructions = readFile(getAppDir() / "troofregression2.txt").split(',')
+    instructions = readFile(parentDir(currentSourcePath) / "troofregression2.txt").split(',')
     programs = "abcdefghijklmnop"
 
   proc dance(dancers: string): string =
diff --git a/tests/async/tasyncfile.nim b/tests/async/tasyncfile.nim
index 3043b680a..d95850c31 100644
--- a/tests/async/tasyncfile.nim
+++ b/tests/async/tasyncfile.nim
@@ -53,8 +53,7 @@ proc main() {.async.} =
 
   # Issue #7347
   block:
-    let appDir = getAppDir()
-    var file = openAsync(appDir & DirSep & "hello.txt")
+    var file = openAsync( parentDir(currentSourcePath) / "hello.txt")
     echo file.getFileSize()
     echo await file.readAll()
     echo file.getFilePos()
diff --git a/tests/ccgbugs/tconstobj.nim b/tests/ccgbugs/tconstobj.nim
deleted file mode 100644
index 51cf661ee..000000000
--- a/tests/ccgbugs/tconstobj.nim
+++ /dev/null
@@ -1,16 +0,0 @@
-discard """
-  output: '''(FirstName: "James", LastName: "Franco")'''
-"""
-
-# bug #1547
-import tables
-
-type Person* = object
-    FirstName*: string
-    LastName*: string
-
-let people = {
-    "001": Person(FirstName: "James", LastName: "Franco")
-}.toTable()
-
-echo people["001"]
diff --git a/tests/collections/tsets.nim b/tests/collections/thashsets.nim
index cd4401511..cd4401511 100644
--- a/tests/collections/tsets.nim
+++ b/tests/collections/thashsets.nim
diff --git a/tests/compilerapi/tcompilerapi.nim b/tests/compilerapi/tcompilerapi.nim
index 30007eff0..2a7db04eb 100644
--- a/tests/compilerapi/tcompilerapi.nim
+++ b/tests/compilerapi/tcompilerapi.nim
@@ -15,7 +15,7 @@ import std / [os]
 
 proc main() =
   let std = findNimStdLibCompileTime()
-  var intr = createInterpreter("myscript.nim", [std, getAppDir()])
+  var intr = createInterpreter("myscript.nim",[std, parentDir(currentSourcePath)])
   intr.implementRoutine("*", "exposed", "addFloats", proc (a: VmArgs) =
     setResult(a, getFloat(a, 0) + getFloat(a, 1) + getFloat(a, 2))
   )
@@ -51,4 +51,3 @@ block issue9180:
 
   evalString("echo 10+1")
   evalString("echo 10+2")
-
diff --git a/tests/concepts/trandom_vars.nim b/tests/concepts/trandomvars2.nim
index 861e876a7..861e876a7 100644
--- a/tests/concepts/trandom_vars.nim
+++ b/tests/concepts/trandomvars2.nim
diff --git a/tests/iter/tconcat.nim b/tests/iter/titerconcat.nim
index 477ac5e26..477ac5e26 100644
--- a/tests/iter/tconcat.nim
+++ b/tests/iter/titerconcat.nim
diff --git a/tests/macros/tgensym.nim b/tests/macros/tmacrogensym.nim
index 1237b8bf7..1237b8bf7 100644
--- a/tests/macros/tgensym.nim
+++ b/tests/macros/tmacrogensym.nim
diff --git a/tests/metatype/ttypeclasses.nim b/tests/metatype/tmeta_typeclasses.nim
index 720527088..720527088 100644
--- a/tests/metatype/ttypeclasses.nim
+++ b/tests/metatype/tmeta_typeclasses.nim
diff --git a/tests/metatype/tmatrix.nim b/tests/metatype/tmetatypematrix.nim
index 076009eb9..076009eb9 100644
--- a/tests/metatype/tmatrix.nim
+++ b/tests/metatype/tmetatypematrix.nim
diff --git a/tests/misc/tradix.nim b/tests/misc/tradix.nim
index 5009dfcfb..e6dde73f6 100644
--- a/tests/misc/tradix.nim
+++ b/tests/misc/tradix.nim
@@ -126,7 +126,7 @@ proc excl*(r: PRadixNode, a: ByteAddress): bool =
 proc addLeaf(r: var PRadixNode, a: int): bool =
   if r == nil:
     # a linear node:
-    var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear)))
+    var x = cast[ptr TRadixNodeLinear](alloc0(sizeof(TRadixNodeLinear)))
     x.kind = rnLeafLinear
     x.len = 1'i8
     x.keys[0] = toU8(a)
@@ -162,7 +162,7 @@ proc addInner(r: var PRadixNode, a: int, d: int): bool =
   var k = a shr d and 0xff
   if r == nil:
     # a linear node:
-    var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear)))
+    var x = cast[ptr TRadixNodeLinear](alloc0(sizeof(TRadixNodeLinear)))
     x.kind = rnLinear
     x.len = 1'i8
     x.keys[0] = toU8(k)
@@ -246,99 +246,3 @@ proc main() =
   for x in elements(r): echo(x)
 
 main()
-
-
-when false:
-  proc traverse(r: PRadixNode, prefix: int, d: int) =
-    if r == nil: return
-    case r.kind
-    of rnLeafBits:
-      assert(d == 0)
-      var x = cast[ptr TRadixNodeLeafBits](r)
-      # iterate over any bit:
-      for i in 0..high(x.b):
-        if x.b[i] != 0: # test all bits for zero
-          for j in 0..BitsPerUnit-1:
-            if testBit(x.b[i], j):
-              visit(prefix or i*BitsPerUnit+j)
-    of rnLeafLinear:
-      assert(d == 0)
-      var x = cast[ptr TRadixNodeLeafLinear](r)
-      for i in 0..ze(x.len)-1:
-        visit(prefix or ze(x.keys[i]))
-    of rnFull:
-      var x = cast[ptr TRadixNodeFull](r)
-      for i in 0..high(r.b):
-        if r.b[i] != nil:
-          traverse(r.b[i], prefix or (i shl d), d-8)
-    of rnLinear:
-      var x = cast[ptr TRadixNodeLinear](r)
-      for i in 0..ze(x.len)-1:
-        traverse(x.vals[i], prefix or (ze(x.keys[i]) shl d), d-8)
-
-  type
-    TRadixIter {.final.} = object
-      r: PRadixNode
-      p: int
-      x: int
-
-  proc init(i: var TRadixIter, r: PRadixNode) =
-    i.r = r
-    i.x = 0
-    i.p = 0
-
-  proc nextr(i: var TRadixIter): PRadixNode =
-    if i.r == nil: return nil
-    case i.r.kind
-    of rnFull:
-      var r = cast[ptr TRadixNodeFull](i.r)
-      while i.x <= high(r.b):
-        if r.b[i.x] != nil:
-          i.p = i.x
-          return r.b[i.x]
-        inc(i.x)
-    of rnLinear:
-      var r = cast[ptr TRadixNodeLinear](i.r)
-      if i.x < ze(r.len):
-        i.p = ze(r.keys[i.x])
-        result = r.vals[i.x]
-        inc(i.x)
-    else: assert(false)
-
-  proc nexti(i: var TRadixIter): int =
-    result = -1
-    case i.r.kind
-    of rnLeafBits:
-      var r = cast[ptr TRadixNodeLeafBits](i.r)
-      # iterate over any bit:
-      for i in 0..high(r.b):
-        if x.b[i] != 0: # test all bits for zero
-          for j in 0..BitsPerUnit-1:
-            if testBit(x.b[i], j):
-              visit(prefix or i*BitsPerUnit+j)
-    of rnLeafLinear:
-      var r = cast[ptr TRadixNodeLeafLinear](i.r)
-      if i.x < ze(r.len):
-        result = ze(r.keys[i.x])
-        inc(i.x)
-
-  iterator elements(r: PRadixNode): ByteAddress {.inline.} =
-    var
-      a, b, c, d: TRadixIter
-    init(a, r)
-    while true:
-      var x = nextr(a)
-      if x != nil:
-        init(b, x)
-        while true:
-          var y = nextr(b)
-          if y != nil:
-            init(c, y)
-            while true:
-              var z = nextr(c)
-              if z != nil:
-                init(d, z)
-                while true:
-                  var q = nexti(d)
-                  if q != -1:
-                    yield a.p shl 24 or b.p shl 16 or c.p shl 8 or q
diff --git a/tests/stdlib/tsqlparser.nim b/tests/stdlib/tsqlparser.nim
index 4a7b2f7d7..11ee22e2b 100644
--- a/tests/stdlib/tsqlparser.nim
+++ b/tests/stdlib/tsqlparser.nim
@@ -6,7 +6,7 @@ discard """
 
 import parsesql, streams, os
 
-var tree = parseSql(newFileStream(getAppDir() / "somesql.sql"), "somesql")
+var tree = parseSql(newFileStream(parentDir(currentSourcePath) / "somesql.sql"), "somesql")
 discard renderSql(tree)
 
 echo "true"
diff --git a/tests/stdlib/tstdlib_various.nim b/tests/stdlib/tstdlib_various.nim
index 7abc9a391..d1723df78 100644
--- a/tests/stdlib/tstdlib_various.nim
+++ b/tests/stdlib/tstdlib_various.nim
@@ -219,7 +219,7 @@ block tsplit2:
 
 block tsqlparser:
   # Just check that we can parse 'somesql' and render it without crashes.
-  var tree = parseSql(newFileStream(getAppDir() / "somesql.sql"), "somesql")
+  var tree = parseSql(newFileStream( parentDir(currentSourcePath) / "somesql.sql"), "somesql")
   discard renderSql(tree)
 
 
diff --git a/tests/system/tostring.nim b/tests/system/tostring.nim
index 04b37f133..ea4a44417 100644
--- a/tests/system/tostring.nim
+++ b/tests/system/tostring.nim
@@ -1,5 +1,5 @@
 discard """
-  output: ""
+  output: "DONE: tostring.nim"
 """
 
 doAssert "@[23, 45]" == $(@[23, 45])
@@ -115,3 +115,6 @@ block:
   var s: string
   s.addQuoted a2
   doAssert s == "\"fo\\\"o2\""
+
+
+echo "DONE: tostring.nim"
diff --git a/tests/types/tissues.nim b/tests/types/tissues_types.nim
index 97c796302..97c796302 100644
--- a/tests/types/tissues.nim
+++ b/tests/types/tissues_types.nim
diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim
index 38fcdd844..021fcb728 100644
--- a/tests/vm/tconstobj.nim
+++ b/tests/vm/tconstobj.nim
@@ -1,10 +1,12 @@
 discard """
-  output: '''(name: "hello")
-(-1, 0)'''
+  output: '''
+(name: "hello")
+(-1, 0)
+(FirstName: "James", LastName: "Franco")
+'''
 """
 
 # bug #2774, bug #3195
-
 type Foo = object
   name: string
 
@@ -14,7 +16,6 @@ const fooArray = [
 
 echo fooArray[0]
 
-
 type
     Position = object
         x, y: int
@@ -34,3 +35,16 @@ const
      ]
 
 echo offset[1]
+
+# bug #1547
+import tables
+
+type Person* = object
+    FirstName*: string
+    LastName*: string
+
+let people = {
+    "001": Person(FirstName: "James", LastName: "Franco")
+}.toTable()
+
+echo people["001"]
diff --git a/tests/vm/tmitems.nim b/tests/vm/tmitems_vm.nim
index 87835d1cd..87835d1cd 100644
--- a/tests/vm/tmitems.nim
+++ b/tests/vm/tmitems_vm.nim
diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim
index 85de26e39..35deea224 100644
--- a/tests/vm/tvmmisc.nim
+++ b/tests/vm/tvmmisc.nim
@@ -70,7 +70,8 @@ block:
 # Tests for VM ops
 block:
   static:
-    assert "vm" in getProjectPath()
+    # for joint test, the project path is different
+    assert "vm" in getProjectPath() or "Nim" in getProjectPath()
 
     let b = getEnv("UNSETENVVAR")
     assert b == ""