]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Added support for multiple testcases in one directory.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 22 Jan 2007 20:41:00 +0000 (20:41 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 22 Jan 2007 20:41:00 +0000 (20:41 +0000)
darcs-hash:20070122204131-f2ef6-600c3f378c5b185faf46efde5fec956b21369876.gz

tests/README.tests
tests/tester.py

index b2eb387afb58f4e5569a1af20dfd53c05436ec64..245b774e0d1c1e8ee44428c559d2ce7798715cfc 100644 (file)
@@ -8,12 +8,21 @@ directory structure.
 Structure of a Testcase
 -----------------------
 
-A directory contains the testcase if it contains at least one of these
-files: Makefile.test, runtest.
+A directory contains the testcase if it contains at least one file
+that matches runtest* pattern.
 
 * Testcase Definition:
 
-  - runtest (mandatory): is the executable that runs the test(s).
+  This is the description of special files in the testcase
+  directory. Besides these files, testcase directory contains all the
+  other files needed to run the testcase (e.g. sources, config.omk
+  etc.)
+
+  - runtest*: is the executable that runs the test(s). It is possible
+    to have more files in a testcase directory which begins with
+    runtest. In that case all these files will be executed in
+    alphabetical order as a separate testcases. The goal is to be able
+    to write several tests on the same structure of files and directories.
 
   - rules: Specifies the rules this testcase applies to. The syntax of
     this files is describes in section Rules description.
index 898fbb84a3d149eb814619337b43c54a873c9c2c..1961bcde8b4025144c20d57150471c357492081a 100755 (executable)
@@ -1,9 +1,5 @@
 #!/usr/bin/env python
 
-### TODO: allow to run several tests in one directory - possible
-### runtest1, runtest2 etc. Use it for generated headers test to check
-### local and global config separately.
-
 import os
 import os.path
 import sys
@@ -12,6 +8,7 @@ import shutil
 import subprocess
 import time
 from xml.sax.saxutils import escape
+import fnmatch
 
 sys.path.append("..")
 import rulesdef
@@ -139,8 +136,9 @@ class ResultEntry:
         return s
 
 class TestCase:
-    def __init__(self, directory):
+    def __init__(self, directory, executable):
         self.directory = directory      # Absolute directory
+        self.executable = executable
         self.name = self._getName()
         self._whichRules()
 
@@ -148,6 +146,9 @@ class TestCase:
         name = self.directory
         if name.startswith(testsRoot+"/"):
             name = name[len(testsRoot)+1:]
+        testSuffix = re.match("^runtest[-_. :]*(.*)", self.executable).group(1)
+        if testSuffix:
+            name+=" "+testSuffix
         return name
 
     def _whichRules(self):
@@ -222,7 +223,7 @@ class TestCase:
 
     def _execRuntest(self, log):
         startTime = time.clock()
-        pipe = subprocess.Popen("./runtest", stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
+        pipe = subprocess.Popen("./"+self.executable, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
         endTime = time.clock()
         (output, errors) = pipe.communicate()
         ret = pipe.returncode
@@ -248,18 +249,18 @@ class TestCase:
 
 
 testsRoot = os.path.dirname(os.path.abspath(__file__))
-if not os.path.exists(os.path.join(testsRoot, "runtests.py")): raise "Can't find tests root directory!"
+if not os.path.exists(os.path.join(testsRoot, "tester.py")): raise "Can't find tests root directory!"
 os.environ['OMK_TESTSROOT'] = testsRoot
 
 results = Results()
 
 for dirpath, dirnames, filenames in os.walk(testsRoot):
-    if not ("Makefile.test" in filenames or \
-            "runtest" in filenames):
-        continue
-    t = TestCase(dirpath)
-    t.run()
-    results[t.name] = t.results
+    executables = fnmatch.filter(filenames, "runtest*")
+    if not executables: continue
+    for exe in executables:
+        t = TestCase(dirpath, exe)
+        t.run()
+        results[t.name] = t.results
 
 os.chdir(testsRoot)
 results.save()