bf96a722bc
First of we apply the wanted lints etc we prefer. This includes but isn't limited to using types (i.e. no "var") and being explicit about creation (i.e. no missing "new"). Change-Id: I516bccdac9760221ea5311af4567466bb4a65c77 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341960 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Alexander Thomas <athom@google.com>
82 lines
2.7 KiB
Python
82 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2023, 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.
|
|
"""frontend_server 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 importlib.util
|
|
import importlib.machinery
|
|
import os.path
|
|
import subprocess
|
|
|
|
USE_PYTHON3 = True
|
|
|
|
|
|
def load_source(modname, filename):
|
|
loader = importlib.machinery.SourceFileLoader(modname, filename)
|
|
spec = importlib.util.spec_from_file_location(modname,
|
|
filename,
|
|
loader=loader)
|
|
module = importlib.util.module_from_spec(spec)
|
|
# The module is always executed and not cached in sys.modules.
|
|
# Uncomment the following line to cache the module.
|
|
# sys.modules[module.__name__] = module
|
|
loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def runSmokeTest(input_api, output_api):
|
|
hasChangedFiles = False
|
|
for git_file in input_api.AffectedTextFiles():
|
|
filename = git_file.AbsoluteLocalPath()
|
|
if filename.endswith(".dart"):
|
|
hasChangedFiles = True
|
|
break
|
|
|
|
if hasChangedFiles:
|
|
local_root = input_api.change.RepositoryRoot()
|
|
utils = 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', 'frontend_server', 'test',
|
|
'quick_smoke_git_test.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: frontend_server 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('Kernel 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)
|