Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: third_party/closure_compiler/compiler_test.py

Issue 2930773003: Closure compilation: Modify compile_js2.py to not swallow errors. (Closed)
Patch Set: More changes. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 from ast import literal_eval 6 from ast import literal_eval
7 import os 7 import os
8 import tempfile 8 import tempfile
9 import unittest 9 import unittest
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 def _runChecker(self, source_code, needs_output, closure_args=None): 46 def _runChecker(self, source_code, needs_output, closure_args=None):
47 file_path = "/script.js" 47 file_path = "/script.js"
48 FileCache._cache[file_path] = source_code 48 FileCache._cache[file_path] = source_code
49 out_file, out_map = self._createOutFiles() 49 out_file, out_map = self._createOutFiles()
50 args = _COMMON_CLOSURE_ARGS + (closure_args or []) 50 args = _COMMON_CLOSURE_ARGS + (closure_args or [])
51 if needs_output: 51 if needs_output:
52 args.remove("checks_only") 52 args.remove("checks_only")
53 53
54 sources = [file_path, _CHROME_SEND_EXTERNS] 54 sources = [file_path, _CHROME_SEND_EXTERNS]
55 found_errors, stderr = self._checker.check(sources, 55 return_code, found_errors, stderr = self._checker.check(
56 out_file=out_file, 56 sources,
57 closure_args=args) 57 out_file=out_file,
58 closure_args=args)
58 return found_errors, stderr, out_file, out_map 59 return found_errors, stderr, out_file, out_map
59 60
60 def _runCheckerTestExpectError(self, source_code, expected_error, 61 def _runCheckerTestExpectError(self, source_code, expected_error,
61 closure_args=None): 62 closure_args=None):
62 _, stderr, out_file, out_map = self._runChecker( 63 _, stderr, out_file, out_map = self._runChecker(
63 source_code, needs_output=False, closure_args=closure_args) 64 source_code, needs_output=False, closure_args=closure_args)
64 65
65 self.assertTrue(expected_error in stderr, 66 self.assertTrue(expected_error in stderr,
66 msg="Expected chunk: \n%s\n\nOutput:\n%s\n" % ( 67 msg="Expected chunk: \n%s\n\nOutput:\n%s\n" % (
67 expected_error, stderr)) 68 expected_error, stderr))
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 """ 367 """
367 args = ['warning_level=VERBOSE'] 368 args = ['warning_level=VERBOSE']
368 self._runCheckerTestExpectError(template % '', 'Missing return', 369 self._runCheckerTestExpectError(template % '', 'Missing return',
369 closure_args=args) 370 closure_args=args)
370 self._runCheckerTestExpectSuccess(template % 'assertNotReached();', 371 self._runCheckerTestExpectSuccess(template % 'assertNotReached();',
371 closure_args=args) 372 closure_args=args)
372 373
373 374
374 if __name__ == "__main__": 375 if __name__ == "__main__":
375 unittest.main() 376 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698