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.
#!/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
import subprocess
import time
from xml.sax.saxutils import escape
+import fnmatch
sys.path.append("..")
import rulesdef
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()
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):
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
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()