[poppler] regtest/Printer.py regtest/TestRun.py

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sat Dec 29 10:45:27 PST 2012


 regtest/Printer.py |   25 +++++++++++++++++++------
 regtest/TestRun.py |   18 +++++++++---------
 2 files changed, 28 insertions(+), 15 deletions(-)

New commits:
commit bf5ef68c89d4189b18458b764f807cfc6599bad7
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sat Dec 29 19:43:11 2012 +0100

    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.

diff --git a/regtest/Printer.py b/regtest/Printer.py
index 2293178..0b0b34a 100644
--- a/regtest/Printer.py
+++ b/regtest/Printer.py
@@ -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:
diff --git a/regtest/TestRun.py b/regtest/TestRun.py
index 5564757..8f8513c 100644
--- a/regtest/TestRun.py
+++ b/regtest/TestRun.py
@@ -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


More information about the poppler mailing list