| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 # for details. All rights reserved. Use of this source code is governed by a | |
| 3 # BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import os | |
| 6 import subprocess | |
| 7 | |
| 8 LICENSE_RE = ("Copyright \(c\) 2011, the Dart project authors. " + | |
| 9 "Please see the AUTHORS file") | |
| 10 | |
| 11 def AllTextFiles(x): | |
| 12 return x.IsTextFile() | |
| 13 | |
| 14 | |
| 15 def NotXmlFiles(x): | |
| 16 name = x.LocalPath() | |
| 17 return not (name.endswith(".xml") or name.endswith(".xsl")) | |
| 18 | |
| 19 | |
| 20 def CannedChecks(results, input_api, output_api): | |
| 21 can = input_api.canned_checks | |
| 22 results.extend(can.CheckChangeHasNoStrayWhitespace(input_api, output_api, | |
| 23 AllTextFiles)) | |
| 24 results.extend(can.CheckChangeHasNoCrAndHasOnlyOneEol(input_api, output_api, | |
| 25 AllTextFiles)) | |
| 26 results.extend(can.CheckChangeHasNoTabs(input_api, output_api, AllTextFiles)) | |
| 27 results.extend(can.CheckLongLines(input_api, output_api, 80, NotXmlFiles)) | |
| 28 results.extend(can.CheckLicense(input_api, output_api, LICENSE_RE, | |
| 29 AllTextFiles)) | |
| 30 | |
| 31 | |
| 32 def RunTests(results, input_api, output_api): | |
| 33 if os.system("make -q || make") != 0: | |
| 34 results.append(output_api.PresubmitError("Make failed")) | |
| 35 return | |
| 36 | |
| 37 child = subprocess.Popen(["./doit.sh"], stdout=subprocess.PIPE, | |
| 38 stderr=subprocess.STDOUT) | |
| 39 (stdout, stderr) = child.communicate() | |
| 40 if child.returncode != 0: | |
| 41 for line in stdout.split("\n"): | |
| 42 if line.find(": warning: ") == -1: | |
| 43 print line | |
| 44 results.append(output_api.PresubmitError("Grammar tests failed")) | |
| 45 | |
| 46 | |
| 47 def CheckChange(input_api, output_api, committing): | |
| 48 results = [] | |
| 49 RunTests(results, input_api, output_api) | |
| 50 CannedChecks(results, input_api, output_api) | |
| 51 return results | |
| 52 | |
| 53 | |
| 54 def CheckChangeOnUpload(input_api, output_api): | |
| 55 return CheckChange(input_api, output_api, False) | |
| 56 | |
| 57 | |
| 58 def CheckChangeOnCommit(input_api, output_api): | |
| 59 return CheckChange(input_api, output_api, True) | |
| OLD | NEW |