summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-01-17 01:18:57 +0100
committerAraq <rumpf_a@web.de>2014-01-17 01:18:57 +0100
commitfc452787e7bba3301642c012fe8e2cdea243993b (patch)
tree07356b86db49e3d3f7afcc265c1089dfd61469b9 /tests
parenta1713bc2f95ddfa6b042315196607f7d5a01d135 (diff)
downloadNim-fc452787e7bba3301642c012fe8e2cdea243993b.tar.gz
better html generator for the tester; fixes some VM bugs
Diffstat (limited to 'tests')
-rw-r--r--tests/testament/backend.nim3
-rw-r--r--tests/testament/categories.nim10
-rw-r--r--tests/testament/htmlgen.nim48
-rw-r--r--tests/testament/tester.nim2
4 files changed, 45 insertions, 18 deletions
diff --git a/tests/testament/backend.nim b/tests/testament/backend.nim
index 500535d9b..87ac10b1f 100644
--- a/tests/testament/backend.nim
+++ b/tests/testament/backend.nim
@@ -77,7 +77,8 @@ proc getMachine*: MachineId =
                          name, system.hostOS, system.hostCPU).MachineId
 
 proc getCommit: CommitId =
-  let hash = "git log -n 1"()
+  const commLen = "commit ".len
+  let hash = "git log -n 1"()[commLen..commLen+10]
   let branch = "git symbolic-ref --short HEAD"()
   if hash.len == 0 or branch.len == 0: quit "cannot determine git HEAD"
   
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 68a61a973..5dd841447 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -221,6 +221,14 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
 
 const AdditionalCategories = ["debugger", "tools", "examples", "stdlib"]
 
+proc `&.?`(a, b: string): string =
+  # candidate for the stdlib?
+  result = if b.startswith(a): b else: a & b
+
+proc `&?.`(a, b: string): string =
+  # candidate for the stdlib?
+  result = if a.endswith(b): a else: a & b
+
 proc processCategory(r: var TResults, cat: Category, options: string) =
   case cat.string.normalize
   of "rodfiles":
@@ -252,5 +260,5 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
     compileExample(r, "examples/gtk/*.nim", options, cat)
     compileExample(r, "examples/talk/*.nim", options, cat)
   else:
-    for name in os.walkFiles(cat.string / "t*.nim"):
+    for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
       testSpec r, makeTest(name, options, cat)
diff --git a/tests/testament/htmlgen.nim b/tests/testament/htmlgen.nim
index 4abcacbd4..e42b88070 100644
--- a/tests/testament/htmlgen.nim
+++ b/tests/testament/htmlgen.nim
@@ -47,39 +47,57 @@ div.tabContent.hide { display: none; }
     function init() {
       // Grab the tab links and content divs from the page
       var tabListItems = document.getElementById('tabs').childNodes;
-      for ( var i = 0; i < tabListItems.length; i++ ) {
-        if ( tabListItems[i].nodeName == "LI" ) {
-          var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
-          var id = getHash( tabLink.getAttribute('href') );
+      for (var i = 0; i < tabListItems.length; i++) {
+        if (tabListItems[i].nodeName == "LI") {
+          var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
+          var id = getHash(tabLink.getAttribute('href'));
           tabLinks[id] = tabLink;
-          contentDivs[id] = document.getElementById( id );
+          contentDivs[id] = document.getElementById(id);
         }
       }
       // Assign onclick events to the tab links, and
       // highlight the first tab
       var i = 0;
-      for ( var id in tabLinks ) {
+      for (var id in tabLinks) {
         tabLinks[id].onclick = showTab;
         tabLinks[id].onfocus = function() { this.blur() };
-        if ( i == 0 ) tabLinks[id].className = 'selected';
+        if (i == 0) tabLinks[id].className = 'selected';
         i++;
       }
       // Hide all content divs except the first
       var i = 0;
-      for ( var id in contentDivs ) {
-        if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
+      for (var id in contentDivs) {
+        if (i != 0) contentDivs[id].className = 'tabContent hide';
         i++;
       }
     }
 
-    function getFirstChildWithTagName( element, tagName ) {
-      for ( var i = 0; i < element.childNodes.length; i++ ) {
-        if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
+    function showTab() {
+      var selectedId = getHash(this.getAttribute('href'));
+
+      // Highlight the selected tab, and dim all others.
+      // Also show the selected content div, and hide all others.
+      for (var id in contentDivs) {
+        if (id == selectedId) {
+          tabLinks[id].className = 'selected';
+          contentDivs[id].className = 'tabContent';
+        } else {
+          tabLinks[id].className = '';
+          contentDivs[id].className = 'tabContent hide';
+        }
+      }
+      // Stop the browser following the link
+      return false;
+    }
+
+    function getFirstChildWithTagName(element, tagName) {
+      for (var i = 0; i < element.childNodes.length; i++) {
+        if (element.childNodes[i].nodeName == tagName) return element.childNodes[i];
       }
     }
-    function getHash( url ) {
-      var hashPos = url.lastIndexOf ( '#' );
-      return url.substring( hashPos + 1 );
+    function getHash(url) {
+      var hashPos = url.lastIndexOf('#');
+      return url.substring(hashPos + 1);
     }
     </script>
 
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 61d0072e3..8abea8224 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -245,7 +245,7 @@ proc main() =
   case action
   of "all":
     for kind, dir in walkDir("tests"):
-      if kind == pcDir and dir != "testament":
+      if kind == pcDir and dir notin ["testament", "testdata", "nimcache"]:
         processCategory(r, Category(dir), p.cmdLineRest.string)
     for a in AdditionalCategories:
       processCategory(r, Category(a), p.cmdLineRest.string)