From 3b1b1b57c73bebec2dae631fa650b3377238e00f Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 26 Mar 2015 12:02:16 +0900 Subject: [PATCH] Bug 1147723 - Avoid non TEST_PASS/TEST_UNEXPECTED_FAIL output from test_files.py. r=gps Instead, capture the output and check it's being printed. --- .../mozpack/test/support/minify_js_verify.py | 8 +++++++- python/mozbuild/mozpack/test/test_files.py | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/python/mozbuild/mozpack/test/support/minify_js_verify.py b/python/mozbuild/mozpack/test/support/minify_js_verify.py index d7fa5072c590..8e4e8b7590b6 100644 --- a/python/mozbuild/mozpack/test/support/minify_js_verify.py +++ b/python/mozbuild/mozpack/test/support/minify_js_verify.py @@ -2,10 +2,16 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +from __future__ import print_function import sys if len(sys.argv) != 4: raise Exception('Usage: minify_js_verify ') -sys.exit(int(sys.argv[1])) +retcode = int(sys.argv[1]) + +if retcode: + print('Error message', file=sys.stderr) + +sys.exit(retcode) diff --git a/python/mozbuild/mozpack/test/test_files.py b/python/mozbuild/mozpack/test/test_files.py index dd38749280ac..228c0bd78709 100644 --- a/python/mozbuild/mozpack/test/test_files.py +++ b/python/mozbuild/mozpack/test/test_files.py @@ -4,7 +4,10 @@ from mozbuild.util import ensureParentDir -from mozpack.errors import ErrorMessage +from mozpack.errors import ( + ErrorMessage, + errors, +) from mozpack.files import ( AbsoluteSymlinkFile, DeflatedFile, @@ -40,6 +43,7 @@ import sys import mozpack.path as mozpath from tempfile import mkdtemp from io import BytesIO +from StringIO import StringIO from xpt import Typelib @@ -795,10 +799,16 @@ class TestMinifiedJavaScript(TestWithTmpDir): def test_minified_verify_failure(self): orig_f = GeneratedFile('\n'.join(self.orig_lines)) + errors.out = StringIO() min_f = MinifiedJavaScript(orig_f, verify_command=self._verify_command('1')) mini_lines = min_f.open().readlines() + output = errors.out.getvalue() + errors.out = sys.stderr + self.assertEqual(output, + 'Warning: JS minification verification failed for :\n' + 'Warning: Error message\n') self.assertEqual(mini_lines, orig_f.open().readlines())