| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 # Copyright (c) 2013, 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 """ | 
|  | 6 Presubmit tests for dom tools. | 
|  | 7 | 
|  | 8 This file is run by git_cl or gcl when an upload or submit happens with | 
|  | 9 any files at this level or lower are in the change list. | 
|  | 10 | 
|  | 11 See: http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts | 
|  | 12 """ | 
|  | 13 | 
|  | 14 | 
|  | 15 import os | 
|  | 16 | 
|  | 17 | 
|  | 18 def _AnySdkFiles(input_api): | 
|  | 19   """ Returns true if any of the changed files are in the sdk, meaning we should | 
|  | 20   check that docs.dart was run. | 
|  | 21   """ | 
|  | 22   for f in input_api.change.AffectedFiles(): | 
|  | 23     if f.LocalPath().find('sdk') > -1: | 
|  | 24       return True | 
|  | 25   return False | 
|  | 26 | 
|  | 27 | 
|  | 28 def CheckChangeOnUpload(input_api, output_api): | 
|  | 29   results = [] | 
|  | 30   # TODO(amouravski): uncomment this check once docs.dart is faster. | 
|  | 31   #  if _AnySdkFiles(input_api): | 
|  | 32   #    results.extend(CheckDocs(input_api, output_api)) | 
|  | 33   return results | 
|  | 34 | 
|  | 35 | 
|  | 36 def CheckChangeOnCommit(input_api, output_api): | 
|  | 37   results = [] | 
|  | 38   if _AnySdkFiles(input_api): | 
|  | 39     results.extend(CheckDocs(input_api, output_api)) | 
|  | 40   return results | 
|  | 41 | 
|  | 42 | 
|  | 43 def CheckDocs(input_api, output_api): | 
|  | 44   """Ensure that documentation has been generated if it needs to be generated. | 
|  | 45 | 
|  | 46   Prompts with a warning if documentation needs to be generated. | 
|  | 47   """ | 
|  | 48   results = [] | 
|  | 49 | 
|  | 50   cmd = [os.path.join(input_api.PresubmitLocalPath(), 'dom.py'), 'test_docs'] | 
|  | 51 | 
|  | 52   try: | 
|  | 53     input_api.subprocess.check_output(cmd, | 
|  | 54                                       stderr=input_api.subprocess.STDOUT) | 
|  | 55   except (OSError, input_api.subprocess.CalledProcessError), e: | 
|  | 56     results.append(output_api.PresubmitPromptWarning( | 
|  | 57         ('Docs test failed!%s\nYou should run `dom.py docs`' % ( | 
|  | 58             e if input_api.verbose else '')))) | 
|  | 59 | 
|  | 60   return results | 
| OLD | NEW | 
|---|