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

Unified Diff: PRESUBMIT.py

Issue 2987883002: Don't treat unparseable files as presubmit dartfmt errors. (Closed)
Patch Set: Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 64d30c320755f00223435e713ae9d0f3a8ae9a29..a71d7d55e1b98c03faced6e44430137da5b3768d 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -42,24 +42,20 @@ def _CheckDartFormat(input_api, output_api):
def HasFormatErrors(filename=None, contents=None):
args = [prebuilt_dartfmt, '--set-exit-if-changed']
- if contents:
- process = subprocess.Popen(args,
- stdout=subprocess.PIPE,
- stdin=subprocess.PIPE
- )
- out, err = process.communicate(input=contents)
-
- # There was a bug in the return code dartfmt returns when reading from
- # stdin so we have to check whether the content matches rather than using
- # the return code. When the next version of the dartfmt lands in the sdk
- # we can switch this line to "return process.returncode != 0"
- return out != contents
- else:
- try:
- subprocess.check_output(args + [filename, '-n'])
- except subprocess.CalledProcessError:
- return True
- return False
+ if not contents:
+ args += [filename, '-n']
+
+ process = subprocess.Popen(args,
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE
+ )
+ process.communicate(input=contents)
+
+ # Check for exit code 1 explicitly to distinguish it from a syntax error
+ # in the file (exit code 65). The repo contains many Dart files that are
+ # known to have syntax errors for testing purposes and which can't be
+ # parsed and formatted. Don't treat those as errors.
+ return process.returncode == 1
unformatted_files = []
for git_file in input_api.AffectedTextFiles():
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698