From 946753a3b52fe957ae7d8c4de89f99d91735ab71 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Thu, 27 Mar 2014 08:36:15 +0000 Subject: [PATCH] Ignore spurious messages from OpenJPEG. --- Tests/run.py | 29 +++++++++++++++++++++++++++-- Tests/test_file_jpeg2k.py | 4 ++++ Tests/tester.py | 5 +++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Tests/run.py b/Tests/run.py index 02b633c90..01a3f3603 100644 --- a/Tests/run.py +++ b/Tests/run.py @@ -2,7 +2,7 @@ from __future__ import print_function # minimal test runner -import glob, os, os.path, sys, tempfile +import glob, os, os.path, sys, tempfile, re try: root = os.path.dirname(__file__) @@ -38,6 +38,8 @@ skipped = [] python_options = " ".join(python_options) tester_options = " ".join(tester_options) +ignore_re = re.compile('^ignore: (.*)$', re.MULTILINE) + for file in files: test, ext = os.path.splitext(os.path.basename(file)) if include and test not in include: @@ -48,7 +50,30 @@ for file in files: out = os.popen("%s %s -u %s %s 2>&1" % ( sys.executable, python_options, file, tester_options )) - result = out.read().strip() + result = out.read() + + # Extract any ignore patterns + ignore_pats = ignore_re.findall(result) + result = ignore_re.sub('', result) + + try: + def fix_re(p): + if not p.startswith('^'): + p = '^' + p + if not p.endswith('$'): + p = p + '$' + return p + + ignore_res = [re.compile(fix_re(p), re.MULTILINE) for p in ignore_pats] + except: + print('(bad ignore patterns %r)' % ignore_pats) + ignore_res = [] + + for r in ignore_res: + result = r.sub('', result) + + result = result.strip() + if result == "ok": result = None elif result == "skip": diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index 1230f7977..b11e5e6ab 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -8,6 +8,10 @@ codecs = dir(Image.core) if "jpeg2k_encoder" not in codecs or "jpeg2k_decoder" not in codecs: skip('JPEG 2000 support not available') +# OpenJPEG 2.0.0 outputs this debugging message sometimes; we should +# ignore it---it doesn't represent a test failure. +ignore('Not enough memory to handle tile data') + test_card = Image.open('Tests/images/test-card.png') test_card.load() diff --git a/Tests/tester.py b/Tests/tester.py index 2c6fa071c..d4309e3e6 100644 --- a/Tests/tester.py +++ b/Tests/tester.py @@ -260,6 +260,11 @@ def skip(msg=None): print("skip") os._exit(0) # don't run exit handlers +def ignore(pattern): + """Tells the driver to ignore messages matching the pattern, for the + duration of the current test.""" + print('ignore: %s' % pattern) + def _setup(): global _logfile def report():