Merge pull request #801 from therearesomewhocallmetim/boost_python_tests

Process boost tests in python.
This commit is contained in:
ygorshenin 2015-12-02 13:56:39 +03:00
commit c068fb273c

View file

@ -61,21 +61,24 @@ class TestRunner:
parser.add_option("-u", "--user_resource_path", dest="resource_path", help="Path to resources, styles and classificators (passed to the test executables as --user_resource_path=<value>)")
parser.add_option("-i", "--include", dest="runlist", action="append", default=[], help="Include test into execution, comma separated list with no spaces or individual tests, or both. E.g.: -i one -i two -i three,four,five")
parser.add_option("-e", "--exclude", dest="skiplist", action="append", default=[], help="Exclude test from execution, comma separated list with no spaces or individual tests, or both. E.g.: -i one -i two -i three,four,five")
parser.add_option("-b", "--boost_tests", dest="boost_tests", action="store_true", default=False, help="Treat all the tests as boost tests (their output is different and it must be processed differently).")
(options, args) = parser.parse_args()
self.skiplist = set()
self.runlist = list()
for tests in options.skiplist:
for test in tests.split(","):
self.skiplist.add(test)
for tests in options.runlist:
self.runlist.extend(tests.split(","))
self.boost_tests = options.boost_tests
if self.runlist:
logging.warn("-i option found, the -e option will be ignored")
logging.warn("-i or -b option found, the -e option will be ignored")
self.workspace_path = options.folder
self.logfile = options.output
@ -127,6 +130,11 @@ class TestRunner:
return {TO_RUN:tests_to_run, SKIP:local_skiplist, NOT_FOUND:not_found, WITH_SERVER:tests_with_server}
def test_file_with_keys(self, test_file):
boost_keys = " --report_format=xml --report_level=detailed --log_level=test_suite --log_format=xml " if self.boost_tests else ""
return "{test_file}{boost_keys}{data}{resources}".format(test_file=test_file, boost_keys=boost_keys, data=self.data_path, resources=self.user_resource_path)
def run_tests(self, tests_to_run):
failed = list()
passed = list()
@ -135,7 +143,7 @@ class TestRunner:
self.log_exec_file(test_file)
test_file_with_keys = "{test_file}{data}{resources}".format(test_file=test_file, data=self.data_path, resources=self.user_resource_path)
test_file_with_keys = self.test_file_with_keys(test_file)
logging.info(test_file_with_keys)
process = subprocess.Popen("{tests_path}/{test_file} 2>> {logfile}".
@ -156,6 +164,9 @@ class TestRunner:
def log_exec_file(self, filename, result=None):
if self.boost_tests:
return
logstring = "BEGIN" if result is None else "END" #can be 0 or None. If we omit the explicit check for None, we get wrong result
resstring = (" | result: {returncode}".format(returncode=result) if result is not None else "")
with open(self.logfile, "a") as logf:
@ -192,10 +203,8 @@ class TestRunner:
def execute(self):
categorized_tests = self.categorize_tests()
to_run_and_with_server_keys = [TO_RUN, WITH_SERVER]
random.shuffle(to_run_and_with_server_keys)