Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More options for ModelicaCompliance testing
- Added the ability to add custom flags (to test newInst) - Optionally add a list of tests expected to fail (for Jenkins) Belonging to [master]: - OpenModelica/OMCompiler#2571
- Loading branch information
1 parent
c44a538
commit 66b19e0
Showing
2 changed files
with
85 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
from junit_xml import TestSuite, TestCase | ||
import glob | ||
import simplejson | ||
import subprocess | ||
import time | ||
|
||
def readTest(f, expectedFailures): | ||
cl = ".".join(f.split(".")[:-1]) | ||
name = f.split(".")[-2] | ||
with open(f) as fin: | ||
res = simplejson.load(fin) | ||
if "killed" in res: | ||
tc = TestCase(name, cl, 0, '', '') | ||
tc.add_error_info('Killed or crashed') | ||
return (tc, tc, cl) | ||
|
||
tc1 = TestCase(name, cl, res["time"], res["messages"], '') | ||
tc2 = TestCase(name, cl, res["time"], res["messages"], '') | ||
success = res["success"] | ||
shouldPass = res["shouldPass"] | ||
expectFail = cl in expectedFailures | ||
if expectFail: | ||
if success: | ||
tc1.add_error_info('This testcase started working (failure was expected)') | ||
else: | ||
tc1.add_skipped_info('This testcase still fails (as expected)') | ||
elif not success: | ||
if shouldPass: | ||
tc1.add_error_info('failed') | ||
else: | ||
tc1.add_error_info('expected failure, but passed') | ||
if not success: | ||
if shouldPass: | ||
tc2.add_error_info('failed') | ||
else: | ||
tc2.add_error_info('expected failure, but passed') | ||
return (tc1, tc2, None if success else cl) | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='OpenModelica ModelicaCompliance testing tool') | ||
parser.add_argument('--expectedFailures', default=None) | ||
parser.add_argument('--outPrefix', default="openmodelica") | ||
parser.add_argument('--version', default="OpenModelica ???") | ||
args = parser.parse_args() | ||
expectedFailuresFile = args.expectedFailures | ||
outPrefix = args.outPrefix | ||
version = args.version | ||
|
||
expectedFailures = set() | ||
if expectedFailuresFile: | ||
with open(expectedFailuresFile) as fin: | ||
expectedFailures = set(l.strip() for l in fin.readlines()) | ||
print(expectedFailures) | ||
|
||
res = [readTest(f, expectedFailures) for f in glob.glob("*.res")] | ||
|
||
(tcs1,tcs2,failures) = zip(*res) | ||
ts1 = TestSuite(version, tcs1) | ||
ts2 = TestSuite(version, tcs2) | ||
if outPrefix: | ||
with open("%s.ignore.xml" % outPrefix, "w") as fout: | ||
TestSuite.to_file(fout, [ts1], prettyprint=False) | ||
with open("%s.xml" % outPrefix, "w") as fout: | ||
TestSuite.to_file(fout, [ts2], prettyprint=False) | ||
with open("%s.failures" % outPrefix, "w") as fout: | ||
for fail in failures: | ||
if fail: | ||
fout.write(fail + "\n") |