mirror of
https://github.com/dart-lang/sdk
synced 2024-09-21 10:46:52 +00:00
40f57a819d
This also adds a PRESUBMIT.py, which will run on a commit and warn the committer if the docs need to be regenerated. This only runs if the html_dart2js, et. al. files have been modified. Review URL: https://codereview.chromium.org//13251005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20820 260f80e4-7a28-3924-810f-c04153c831b5
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
"""
|
|
Presubmit tests for dom tools.
|
|
|
|
This file is run by git_cl or gcl when an upload or submit happens with
|
|
any files at this level or lower are in the change list.
|
|
|
|
See: http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts
|
|
"""
|
|
|
|
|
|
import os
|
|
|
|
|
|
def _AnySdkFiles(input_api):
|
|
""" Returns true if any of the changed files are in the sdk, meaning we should
|
|
check that docs.dart was run.
|
|
"""
|
|
for f in input_api.change.AffectedFiles():
|
|
if f.LocalPath().find('sdk') > -1:
|
|
return True
|
|
return False
|
|
|
|
|
|
def CheckChangeOnUpload(input_api, output_api):
|
|
results = []
|
|
# TODO(amouravski): uncomment this check once docs.dart is faster.
|
|
# if _AnySdkFiles(input_api):
|
|
# results.extend(CheckDocs(input_api, output_api))
|
|
return results
|
|
|
|
|
|
def CheckChangeOnCommit(input_api, output_api):
|
|
results = []
|
|
if _AnySdkFiles(input_api):
|
|
results.extend(CheckDocs(input_api, output_api))
|
|
return results
|
|
|
|
|
|
def CheckDocs(input_api, output_api):
|
|
"""Ensure that documentation has been generated if it needs to be generated.
|
|
|
|
Prompts with a warning if documentation needs to be generated.
|
|
"""
|
|
results = []
|
|
|
|
cmd = [os.path.join(input_api.PresubmitLocalPath(), 'dom.py'), 'test_docs']
|
|
|
|
try:
|
|
input_api.subprocess.check_output(cmd,
|
|
stderr=input_api.subprocess.STDOUT)
|
|
except (OSError, input_api.subprocess.CalledProcessError), e:
|
|
results.append(output_api.PresubmitPromptWarning(
|
|
('Docs test failed!%s\nYou should run `dom.py docs`' % (
|
|
e if input_api.verbose else ''))))
|
|
|
|
return results
|