| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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() |
| OLD | NEW |