Bug 1147723 - Avoid non TEST_PASS/TEST_UNEXPECTED_FAIL output from test_files.py. r=gps, a=test-only
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 26 Mar 2015 12:02:16 +0900
changeset 258292 882dd82e8af0
parent 258291 2bc3aac3094b
child 258293 a141c675b405
push id4637
push userryanvm@gmail.com
push date2015-04-06 19:04 +0000
treeherdermozilla-beta@882dd82e8af0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, test-only
bugs1147723
milestone38.0
Bug 1147723 - Avoid non TEST_PASS/TEST_UNEXPECTED_FAIL output from test_files.py. r=gps, a=test-only Instead, capture the output and check it's being printed.
python/mozbuild/mozpack/test/support/minify_js_verify.py
python/mozbuild/mozpack/test/test_files.py
--- a/python/mozbuild/mozpack/test/support/minify_js_verify.py
+++ b/python/mozbuild/mozpack/test/support/minify_js_verify.py
@@ -1,11 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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 <exitcode> <orig> <minified>')
 
-sys.exit(int(sys.argv[1]))
+retcode = int(sys.argv[1])
+
+if retcode:
+    print('Error message', file=sys.stderr)
+
+sys.exit(retcode)
--- a/python/mozbuild/mozpack/test/test_files.py
+++ b/python/mozbuild/mozpack/test/test_files.py
@@ -1,15 +1,18 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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 mozbuild.util import ensureParentDir
 
-from mozpack.errors import ErrorMessage
+from mozpack.errors import (
+    ErrorMessage,
+    errors,
+)
 from mozpack.files import (
     AbsoluteSymlinkFile,
     DeflatedFile,
     Dest,
     ExistingFile,
     FileFinder,
     File,
     GeneratedFile,
@@ -35,16 +38,17 @@ import mozfile
 import mozunit
 import os
 import random
 import string
 import sys
 import mozpack.path
 from tempfile import mkdtemp
 from io import BytesIO
+from StringIO import StringIO
 from xpt import Typelib
 
 
 class TestWithTmpDir(unittest.TestCase):
     def setUp(self):
         self.tmpdir = mkdtemp()
 
         self.symlink_supported = False
@@ -790,20 +794,26 @@ class TestMinifiedJavaScript(TestWithTmp
             verify_command=self._verify_command('0'))
 
         mini_lines = min_f.open().readlines()
         self.assertTrue(mini_lines)
         self.assertTrue(len(mini_lines) < len(self.orig_lines))
 
     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 <unknown>:\n'
+            'Warning: Error message\n')
         self.assertEqual(mini_lines, orig_f.open().readlines())
 
 
 class MatchTestTemplate(object):
     def prepare_match_test(self, with_dotfiles=False):
         self.add('bar')
         self.add('foo/bar')
         self.add('foo/baz')