From 1fff0d53da25c89d5a6a692099207f0f8d377029 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Wed, 27 Mar 2013 23:13:37 +0100 Subject: [PATCH] Improved error messages. --- tests/visual_tests/test.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index 8990e2f1e..63d746c54 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -123,6 +123,7 @@ class Reporting: NOT_FOUND = 2 OTHER = 3 REPLACE = 4 + LOAD_ERROR = 5 def __init__(self, quiet, generate = False, overwrite_failures = False): self.quiet = quiet self.passed = 0 @@ -172,6 +173,14 @@ class Reporting: else: print '\x1b[31m✘\x1b[0m (\x1b[34m%s\x1b[0m)' % message + def load_error(self, name, message): + self.failed += 1 + self.errors.append((self.LOAD_ERROR, name, None, 0, message)) + if self.quiet: + sys.stderr.write('\x1b[31m.\x1b[0m') + else: + print '"%s": error while loading style file: \x1b[31m✘\x1b[0m (\x1b[34m%s\x1b[0m)' % (name, message) + def summary(self): if len(self.errors) == 0: print '\nAll %s visual tests passed: \x1b[1;32m✓ \x1b[0m' % self.passed @@ -179,7 +188,7 @@ class Reporting: print "\nVisual rendering: %s failed / %s passed" % (len(self.errors), self.passed) for idx, error in enumerate(self.errors): if error[0] == self.OTHER: - print str(idx+1) + ") \x1b[31mfailure to run test:\x1b[0m %s" % error[3] + print str(idx+1) + ") \x1b[31mfailure to run test \"%s\":\x1b[0m %s" % (error[1], error[4]) elif error[0] == self.NOT_FOUND: if self.generate: print str(idx+1) + ") Generating reference image: '%s'" % error[2] @@ -242,7 +251,7 @@ def render(config, width, height, bbox, scale_factor, reporting): else: m.zoom_all() except Exception, e: - reporting.other_error(filename, repr(e)) + reporting.load_error(filename, repr(e)) return m for renderer in renderers: