[CFE] Add PRESUBMIT.py that runs a little smoke testing

Runs pkg/front_end/tool/smoke_test_quick.dart if changing either
* A .dart file, or
* A messages.yaml file
inside the front_end folder.

Change-Id: I466fda1436806e280e38f90afe77f1c7aa53d021
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113321
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Jens Johansen 2019-08-16 12:28:07 +00:00 committed by commit-bot@chromium.org
parent 8c392095c6
commit a3b579d5c3

View file

@ -0,0 +1,61 @@
# Copyright (c) 2019, 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.
"""Front-end specific presubmit script.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl.
"""
import imp
import os.path
import subprocess
def runSmokeTest(input_api, output_api):
hasChangedFiles = False
for git_file in input_api.AffectedTextFiles():
filename = git_file.AbsoluteLocalPath()
if filename.endswith(".dart") or filename.endswith("messages.yaml"):
hasChangedFiles = True
break
if hasChangedFiles:
local_root = input_api.change.RepositoryRoot()
utils = imp.load_source('utils',
os.path.join(local_root, 'tools', 'utils.py'))
dart = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dart')
smoke_test = os.path.join(local_root, 'pkg', 'front_end', 'tool',
'smoke_test_quick.dart')
windows = utils.GuessOS() == 'win32'
if windows:
dart += '.exe'
if not os.path.isfile(dart):
print('WARNING: dart not found: %s' % dart)
return []
if not os.path.isfile(smoke_test):
print('WARNING: Front-end smoke test not found: %s' % smoke_test)
return []
args = [dart, smoke_test]
process = subprocess.Popen(
args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
outs, _ = process.communicate()
if process.returncode != 0:
return [output_api.PresubmitError(
'Front-end smoke test failure(s):',
long_text=outs)]
return []
def CheckChangeOnCommit(input_api, output_api):
return runSmokeTest(input_api, output_api)
def CheckChangeOnUpload(input_api, output_api):
return runSmokeTest(input_api, output_api)