summaryrefslogtreecommitdiff
path: root/test/sailtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sailtest.py')
-rw-r--r--test/sailtest.py64
1 files changed, 44 insertions, 20 deletions
diff --git a/test/sailtest.py b/test/sailtest.py
index 612aba2b..5ee87b08 100644
--- a/test/sailtest.py
+++ b/test/sailtest.py
@@ -11,6 +11,24 @@ class color:
FAIL = '\033[91m'
END = '\033[0m'
+def parallel():
+ try:
+ return int(os.environ['TEST_PAR'])
+ except Exception, e:
+ print("Running 4 tests in parallel. Set TEST_PAR to configure")
+ return 4
+
+def chunks(filenames, cores):
+ ys = []
+ chunk = []
+ for filename in filenames:
+ if re.match('.+\.sail', filename):
+ chunk.append(filename)
+ if len(chunk) >= cores:
+ ys.append(list(chunk))
+ chunk = []
+ ys.append(list(chunk))
+ return ys
def step(string):
p = subprocess.Popen(string, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
@@ -28,24 +46,30 @@ def banner(string):
print '-' * len(string)
print string
print '-' * len(string)
+ sys.stdout.flush()
+
+class Results:
+ def __init__(self, name):
+ self.passes = 0
+ self.failures = 0
+ self.xml = ""
+ self.name = name
+
+ def collect(self, tests):
+ for test in tests:
+ _, status = os.waitpid(tests[test], 0)
+ if status != 0:
+ self.failures += 1
+ self.xml += ' <testcase name="{}">\n <error message="fail">fail</error>\n </testcase>\n'.format(test)
+ else:
+ self.passes += 1
+ self.xml += ' <testcase name="{}"/>\n'.format(test)
+ sys.stdout.flush()
+
+ def finish(self):
+ print '{}{} passes and {} failures{}'.format(color.NOTICE, self.passes, self.failures, color.END)
-def collect_results(name, tests):
- passes = 0
- failures = 0
- xml = ""
-
- for test in tests:
- _, status = os.waitpid(tests[test], 0)
- if status != 0:
- failures += 1
- xml += ' <testcase name="{}">\n <error message="fail">fail</error>\n </testcase>\n'.format(test)
- else:
- passes += 1
- xml += ' <testcase name="{}"/>\n'.format(test)
-
- print '{}{} passes and {} failures{}'.format(color.NOTICE, passes, failures, color.END)
-
- time = datetime.datetime.utcnow()
- suite = ' <testsuite name="{}" tests="{}" failures="{}" timestamp="{}">\n{} </testsuite>\n'
- xml = suite.format(name, passes + failures, failures, time, xml)
- return xml
+ time = datetime.datetime.utcnow()
+ suite = ' <testsuite name="{}" tests="{}" failures="{}" timestamp="{}">\n{} </testsuite>\n'
+ self.xml = suite.format(self.name, self.passes + self.failures, self.failures, time, self.xml)
+ return self.xml