Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PRESUBMIT.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5"""CFE et al presubmit python script.
6
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8for more details about the presubmit API built into gcl.
9"""
10
11import importlib.util
12import importlib.machinery
13import os.path
14import subprocess
15
16USE_PYTHON3 = True
17
18
19def load_source(modname, filename):
20 loader = importlib.machinery.SourceFileLoader(modname, filename)
21 spec = importlib.util.spec_from_file_location(modname,
22 filename,
23 loader=loader)
24 module = importlib.util.module_from_spec(spec)
25 # The module is always executed and not cached in sys.modules.
26 # Uncomment the following line to cache the module.
27 # sys.modules[module.__name__] = module
28 loader.exec_module(module)
29 return module
30
31
32def runSmokeTest(input_api, output_api):
33 local_root = input_api.change.RepositoryRoot()
34 utils = load_source('utils', os.path.join(local_root, 'tools', 'utils.py'))
35 dart = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dart')
36 test_helper = os.path.join(local_root, 'pkg', 'front_end',
37 'presubmit_helper.dart')
38
39 windows = utils.GuessOS() == 'win32'
40 if windows:
41 dart += '.exe'
42
43 if not os.path.isfile(dart):
44 print('WARNING: dart not found: %s' % dart)
45 return []
46
47 if not os.path.isfile(test_helper):
48 print('WARNING: CFE et al presubmit_helper not found: %s' % test_helper)
49 return []
50
51 args = [dart, test_helper, input_api.PresubmitLocalPath()]
52 process = subprocess.Popen(args,
53 stdout=subprocess.PIPE,
54 stdin=subprocess.PIPE)
55 outs, _ = process.communicate()
56
57 if process.returncode != 0:
58 return [
59 output_api.PresubmitError('CFE et al presubmit script failure(s):',
60 long_text=outs)
61 ]
62
63 return []
64
65
66def CheckChangeOnCommit(input_api, output_api):
67 return runSmokeTest(input_api, output_api)
68
69
70def CheckChangeOnUpload(input_api, output_api):
71 return runSmokeTest(input_api, output_api)
void print(void *str)
Definition bridge.cpp:126
CheckChangeOnUpload(input_api, output_api)
Definition PRESUBMIT.py:70
CheckChangeOnCommit(input_api, output_api)
Definition PRESUBMIT.py:66
load_source(modname, filename)
Definition PRESUBMIT.py:19
runSmokeTest(input_api, output_api)
Definition PRESUBMIT.py:32
CheckedInSdkPath()
Definition utils.py:499
GuessOS()
Definition utils.py:21