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.
This commit is contained in:
Mike Hommey 2015-03-26 12:02:16 +09:00
parent dc0e825e45
commit 8d7e9d7efb
2 changed files with 18 additions and 2 deletions

View File

@ -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 <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)

View File

@ -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 <unknown>:\n'
'Warning: Error message\n')
self.assertEqual(mini_lines, orig_f.open().readlines())