Chromium Code Reviews| Index: third_party/closure_compiler/compiler_test.py |
| diff --git a/third_party/closure_compiler/compiler_test.py b/third_party/closure_compiler/compiler_test.py |
| index a39776a4193851d81b3b671186fa22f4601de292..a619a46974c94afc99faf370e19b990ad6892dac 100755 |
| --- a/third_party/closure_compiler/compiler_test.py |
| +++ b/third_party/closure_compiler/compiler_test.py |
| @@ -20,6 +20,41 @@ _CR_UI_JS = os.path.join(_RESOURCES_DIR, "cr", "ui.js") |
| _POLYMER_EXTERNS = os.path.join(_SRC_DIR, "third_party", "polymer", "v1_0", |
| "components-chromium", "polymer-externs", |
| "polymer.externs.js") |
| +_COMMON_CLOSURE_ARGS = [ |
|
Dan Beam
2015/06/03 23:39:11
can we share this in gyp/gn/here?
Theresa
2015/06/04 17:44:05
For sharing with here, not that I know of, which i
Dan Beam
2015/06/04 18:35:45
pretty sure GYP is written in Python, btw...
Theresa
2015/06/04 19:21:30
Done.
|
| + "accept_const_keyword", |
| + "compilation_level=SIMPLE_OPTIMIZATIONS", |
| + "extra_annotation_name=attribute", |
| + "extra_annotation_name=element", |
| + "extra_annotation_name=group", |
| + "extra_annotation_name=homepage", |
| + "extra_annotation_name=status", |
| + "extra_annotation_name=submodule", |
| + "jscomp_error=accessControls", |
| + "jscomp_error=ambiguousFunctionDecl", |
| + "jscomp_error=checkStructDictInheritance", |
| + "jscomp_error=checkTypes", |
| + "jscomp_error=checkVars", |
| + "jscomp_error=constantProperty", |
| + "jscomp_error=deprecated", |
| + "jscomp_error=externsValidation", |
| + "jscomp_error=globalThis", |
| + "jscomp_error=invalidCasts", |
| + "jscomp_error=missingProperties", |
| + "jscomp_error=missingReturn", |
| + "jscomp_error=nonStandardJsDocs", |
| + "jscomp_error=suspiciousCode", |
| + "jscomp_error=undefinedNames", |
| + "jscomp_error=undefinedVars", |
| + "jscomp_error=unknownDefines", |
| + "jscomp_error=uselessCode", |
| + "jscomp_error=visibility", |
| + "jscomp_off=duplicate", |
| + "jscomp_off=misplacedTypeAnnotation", |
| + "language_in=ECMASCRIPT5_STRICT", |
| + "polymer_pass", |
| + "source_map_format=V3", |
| + "summary_detail_level=3", |
| +] |
| class CompilerTest(unittest.TestCase): |
| @@ -36,15 +71,19 @@ class CompilerTest(unittest.TestCase): |
| if os.path.exists(file): |
| os.remove(file) |
| - def _runChecker(self, source_code, output_wrapper=None): |
| + def _runChecker(self, source_code, closure_args=None): |
| file_path = "/script.js" |
| FileCache._cache[file_path] = source_code |
| out_file, out_map = self._createOutFiles() |
| + args = [] |
| + args += _COMMON_CLOSURE_ARGS; |
| + if closure_args: |
| + args += closure_args |
| found_errors, stderr = self._checker.check(file_path, |
| externs=[_POLYMER_EXTERNS], |
| out_file=out_file, |
| - output_wrapper=output_wrapper) |
| + closure_args=args) |
| return found_errors, stderr, out_file, out_map |
| def _runCheckerTestExpectError(self, source_code, expected_error): |
| @@ -57,9 +96,9 @@ class CompilerTest(unittest.TestCase): |
| self.assertFalse(os.path.exists(out_map)) |
| def _runCheckerTestExpectSuccess(self, source_code, expected_output=None, |
| - output_wrapper=None): |
| + closure_args=None): |
| found_errors, stderr, out_file, out_map = self._runChecker(source_code, |
| - output_wrapper) |
| + closure_args) |
| self.assertFalse(found_errors, |
| msg="Expected success, but got failure\n\nOutput:\n%s\n" % stderr) |
| @@ -282,9 +321,9 @@ var testScript = function() { |
| """ |
| expected_output = ("""(function(){'use strict';var testScript=function()""" |
| """{console.log("hello world")};})();\n""") |
| - output_wrapper="(function(){%output%})();" |
| + closure_args=["output_wrapper='(function(){%output%})();'"] |
| self._runCheckerTestExpectSuccess(source_code, expected_output, |
| - output_wrapper=output_wrapper) |
| + closure_args) |
| def testCheckMultiple(self): |
| source_file1 = tempfile.NamedTemporaryFile(delete=False) |
| @@ -308,9 +347,9 @@ testScript(); |
| out_file, out_map = self._createOutFiles() |
| sources = [source_file1.name, source_file2.name] |
| externs = [_POLYMER_EXTERNS] |
| - found_errors, stderr = self._checker.check_multiple(sources, |
| - externs=externs, |
| - out_file=out_file) |
| + found_errors, stderr = self._checker.check_multiple( |
| + sources, externs=externs, out_file=out_file, |
| + closure_args=_COMMON_CLOSURE_ARGS) |
| self.assertFalse(found_errors, |
| msg="Expected success, but got failure\n\nOutput:\n%s\n" % stderr) |