diff options
author | dbeam <dbeam@chromium.org> | 2015-05-08 15:46:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-08 22:47:47 +0000 |
commit | 65220f0e00b62e137c58b30dd03116e7be265355 (patch) | |
tree | 6eb3b9871cb9e2aa5cc30c33611c7ec0c3a5c24a /third_party | |
parent | 99875046009b6d4bb30facc58cf1df7851c684a3 (diff) | |
download | chromium_src-65220f0e00b62e137c58b30dd03116e7be265355.zip chromium_src-65220f0e00b62e137c58b30dd03116e7be265355.tar.gz chromium_src-65220f0e00b62e137c58b30dd03116e7be265355.tar.bz2 |
Fix closure + ninja rebuilding issue.
The recently added --js_output_file seems to write output even if
there's a compile error (surprising to me, but I'm not totally sure what
should happen). This results in compile errors only failing on the bots
once (as when they're run again, nothing is rebuilt).
So I'm adding code to remove the output file when there's errors (for
now). This seems slightly better than writing the file to a temporary
location and moving it to the right location in the common case that
everything typechecks cleanly.
R=tbreisacher@chromium.org,twellington@chromium.org
BUG=486093
NOTRY=true
NOTREECHECKS=true
Review URL: https://codereview.chromium.org/1131343002
Cr-Commit-Position: refs/heads/master@{#329026}
Diffstat (limited to 'third_party')
-rwxr-xr-x | third_party/closure_compiler/compile.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/third_party/closure_compiler/compile.py b/third_party/closure_compiler/compile.py index 2b2e7f8..b40dcfc 100755 --- a/third_party/closure_compiler/compile.py +++ b/third_party/closure_compiler/compile.py @@ -73,6 +73,8 @@ class Checker(object): "-XX:+TieredCompilation" ] + _MAP_FILE_FORMAT = "%s.map" + def __init__(self, verbose=False, strict=False): """ Args: @@ -86,7 +88,7 @@ class Checker(object): self._strict = strict self._error_filter = error_filter.PromiseErrorFilter() - def _clean_up(self): + def _nuke_temp_files(self): """Deletes any temp files this class knows about.""" if not self._temp_files: return @@ -190,7 +192,7 @@ class Checker(object): first_declared_in = lambda e: " first declared in " not in e return self._error_filter.filter(filter(first_declared_in, errors)) - def _fix_up_error(self, error): + def _clean_up_error(self, error): """Reverse the effects that funky <include> preprocessing steps have on errors messages. @@ -249,7 +251,7 @@ class Checker(object): if out_file: args += ["--js_output_file=%s" % out_file] - args += ["--create_source_map=%s.map" % out_file] + args += ["--create_source_map=%s" % (self._MAP_FILE_FORMAT % out_file)] if externs: args += ["--externs=%s" % e for e in externs] @@ -274,9 +276,15 @@ class Checker(object): else: # Not a summary. Running the jar failed. Bail. self._log_error(stderr) - self._clean_up() + self._nuke_temp_files() sys.exit(1) + if errors and out_file: + if os.path.exists(out_file): + os.remove(out_file) + if os.path.exists(self._MAP_FILE_FORMAT % out_file): + os.remove(self._MAP_FILE_FORMAT % out_file) + return errors, stderr def check(self, source_file, out_file=None, depends=None, externs=None, @@ -320,17 +328,17 @@ class Checker(object): out_file=out_file, externs=externs, output_wrapper=output_wrapper) filtered_errors = self._filter_errors(errors) - fixed_errors = map(self._fix_up_error, filtered_errors) - output = self._format_errors(fixed_errors) + cleaned_errors = map(self._clean_up_error, filtered_errors) + output = self._format_errors(cleaned_errors) - if fixed_errors: + if cleaned_errors: prefix = "\n" if output else "" self._log_error("Error in: %s%s%s" % (source_file, prefix, output)) elif output: self._log_debug("Output: %s" % output) - self._clean_up() - return bool(fixed_errors), stderr + self._nuke_temp_files() + return bool(cleaned_errors), stderr def check_multiple(self, sources, out_file=None, output_wrapper=None): """Closure compile a set of files and check for errors. @@ -347,7 +355,7 @@ class Checker(object): """ errors, stderr = self._run_js_check(sources, out_file=out_file, output_wrapper=output_wrapper) - self._clean_up() + self._nuke_temp_files() return bool(errors), stderr |