Commit bf5ef68c authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

regtest: Print test results when the test has finished

To make sure the result corresponds to the test now that we are using
multiple threads.
parent 80c7f6aa
......@@ -34,6 +34,8 @@ class Printer:
self._rewrite = self._stream.isatty() and not self._verbose
self._current_line = None
self._tests = {}
self._lock = RLock()
Printer.__single = self
......@@ -82,14 +84,25 @@ class Printer:
self.stderr.write(self._ensure_new_line(msg))
self.stderr.flush()
def print_test_start(self, msg):
self.printout(msg)
def print_test_start(self, doc_path, backend_name, n_doc, total_docs):
with self._lock:
self._tests[(doc_path, backend_name)] = n_doc, total_docs
def print_test_result(self, doc_path, backend_name, msg):
if not self._rewrite:
self.print_test_result_ln(doc_path, backend_name, msg)
return
def print_test_result(self, msg):
self.printout_update(msg)
with self._lock:
n_doc, total_docs = self._tests.pop((doc_path, backend_name))
msg = "Tested '%s' using %s backend (%d/%d): %s" % (doc_path, backend_name, n_doc, total_docs, msg)
self.printout(msg)
def print_test_result_ln(self, msg):
self.printout_update(self._ensure_new_line(msg))
def print_test_result_ln(self, doc_path, backend_name, msg):
with self._lock:
n_doc, total_docs = self._tests.pop((doc_path, backend_name))
msg = "Tested '%s' using %s backend (%d/%d): %s" % (doc_path, backend_name, n_doc, total_docs, msg)
self.printout_ln(msg)
def print_default(self, msg):
if self._verbose:
......
......@@ -71,7 +71,7 @@ class TestRun:
with self._lock:
self._n_tests += 1
self.printer.print_test_start("Testing '%s' using %s backend (%d/%d): " % (doc_path, backend.get_name(), n_doc, total_docs))
self.printer.print_test_start(doc_path, backend.get_name(), n_doc, total_docs)
test_has_md5 = backend.create_refs(doc_path, test_path)
if backend.has_stderr(test_path):
......@@ -81,24 +81,24 @@ class TestRun:
if ref_has_md5 and test_has_md5:
if backend.compare_checksums(refs_path, test_path, not self.config.keep_results, self.config.create_diffs, self.config.update_refs):
# FIXME: remove dir if it's empty?
self.printer.print_test_result("PASS")
self.printer.print_test_result(doc_path, backend.get_name(), "PASS")
with self._lock:
self._n_passed += 1
else:
self.printer.print_test_result_ln("FAIL")
self.printer.print_test_result_ln(doc_path, backend.get_name(), "FAIL")
with self._lock:
self._failed.append("%s (%s)" % (doc_path, backend.get_name()))
return
elif test_has_md5:
if ref_is_crashed:
self.printer.print_test_result_ln("DOES NOT CRASH")
self.printer.print_test_result_ln(doc_path, backend.get_name(), "DOES NOT CRASH")
elif ref_is_failed:
self.printer.print_test_result_ln("DOES NOT FAIL")
self.printer.print_test_result_ln(doc_path, backend.get_name(), "DOES NOT FAIL")
return
test_is_crashed = backend.is_crashed(test_path)
if ref_is_crashed and test_is_crashed:
self.printer.print_test_result("PASS (Expected crash)")
self.printer.print_test_result(doc_path, backend.get_name(), "PASS (Expected crash)")
with self._lock:
self._n_passed += 1
return
......@@ -106,19 +106,19 @@ class TestRun:
test_is_failed = backend.is_failed(test_path)
if ref_is_failed and test_is_failed:
# FIXME: compare status errors
self.printer.print_test_result("PASS (Expected fail with status error %d)" % (test_is_failed))
self.printer.print_test_result(doc_path, backend.get_name(), "PASS (Expected fail with status error %d)" % (test_is_failed))
with self._lock:
self._n_passed += 1
return
if test_is_crashed:
self.printer.print_test_result_ln("CRASH")
self.printer.print_test_result_ln(doc_path, backend.get_name(), "CRASH")
with self._lock:
self._crashed.append("%s (%s)" % (doc_path, backend.get_name()))
return
if test_is_failed:
self.printer.print_test_result_ln("FAIL (status error %d)" % (test_is_failed))
self.printer.print_test_result_ln(doc_path, backend.get_name(), "FAIL (status error %d)" % (test_is_failed))
with self._lock:
self._failed_status_error("%s (%s)" % (doc_path, backend.get_name()))
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment