summary refs log tree commit diff stats
path: root/testament
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-02-02 19:24:55 +0100
committerGitHub <noreply@github.com>2021-02-02 19:24:55 +0100
commitfb80d2ff85fc5db2996d6660075941e1256564fe (patch)
tree1b463d4213dec1a1b75f4cc3a83c6ee81a66ddc0 /testament
parent1d1c831efa7f9bfcc739b2d38a3a839187bc39c6 (diff)
downloadNim-fb80d2ff85fc5db2996d6660075941e1256564fe.tar.gz
IC: bugfixes (WIP) (#16836)
* minor improvements
* IC: added the required logic for compilerProcs
* LazySym ftw
* we need this testing logic
* reimplement the old way we use for module package creation
* fixes a regression; don't pick module names if you can avoid it
Diffstat (limited to 'testament')
-rw-r--r--testament/categories.nim45
1 files changed, 45 insertions, 0 deletions
diff --git a/testament/categories.nim b/testament/categories.nim
index 472c7f263..9b0de13ac 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -499,6 +499,49 @@ proc testNimblePackages(r: var TResults; cat: Category; packageFilter: string, p
   finally:
     if errors == 0: removeDir(packagesDir)
 
+# ---------------- IC tests ---------------------------------------------
+
+proc icTests(r: var TResults; testsDir: string, cat: Category, options: string) =
+  const
+    tooltests = ["compiler/nim.nim", "tools/nimgrep.nim"]
+    writeOnly = " --incremental:writeonly "
+    readOnly = " --incremental:readonly "
+    incrementalOn = " --incremental:on "
+
+  template test(x: untyped) =
+    testSpecWithNimcache(r, makeRawTest(file, x & options, cat), nimcache)
+
+  template editedTest(x: untyped) =
+    var test = makeTest(file, x & options, cat)
+    test.spec.targets = {getTestSpecTarget()}
+    testSpecWithNimcache(r, test, nimcache)
+
+  const tempExt = "_temp.nim"
+  for it in walkDirRec(testsDir / "ic"):
+    if isTestFile(it) and not it.endsWith(tempExt):
+      let nimcache = nimcacheDir(it, options, getTestSpecTarget())
+      removeDir(nimcache)
+
+      let content = readFile(it)
+      for fragment in content.split("#!EDIT!#"):
+        let file = it.replace(".nim", tempExt)
+        writeFile(file, fragment)
+        let oldPassed = r.passed
+        editedTest incrementalOn
+        if r.passed != oldPassed+1: break
+
+  when false:
+    for file in tooltests:
+      let nimcache = nimcacheDir(file, options, getTestSpecTarget())
+      removeDir(nimcache)
+
+      let oldPassed = r.passed
+      test writeOnly
+
+      if r.passed == oldPassed+1:
+        test readOnly
+        if r.passed == oldPassed+2:
+          test readOnly
 
 # ----------------------------------------------------------------------------
 
@@ -665,6 +708,8 @@ proc processCategory(r: var TResults, cat: Category,
       testNimblePackages(r, cat, options, ppTwo)
     of "niminaction":
       testNimInAction(r, cat, options)
+    of "ic":
+      icTests(r, testsDir, cat, options)
     of "untestable":
       # We can't test it because it depends on a third party.
       discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.