| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (C) 2020 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 16 | """Add or update tests to TEST_MAPPING. |
| 17 | |
| 18 | This script uses Bazel to find reverse dependencies on a crate and generates a |
| 19 | TEST_MAPPING file. It accepts the absolute path to a crate as argument. If no |
| 20 | argument is provided, it assumes the crate is the current directory. |
| 21 | |
| 22 | Usage: |
| 23 | $ . build/envsetup.sh |
| 24 | $ lunch aosp_arm64-eng |
| 25 | $ update_crate_tests.py $ANDROID_BUILD_TOP/external/rust/crates/libc |
| 26 | |
| 27 | This script is automatically called by external_updater. |
| 28 | """ |
| 29 | |
| Joel Galenson | 0835244 | 2021-08-20 11:39:48 -0700 | [diff] [blame] | 30 | import argparse |
| 31 | import glob |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 32 | import json |
| 33 | import os |
| 34 | import platform |
| 35 | import subprocess |
| 36 | import sys |
| Joel Galenson | 4a2a3a8 | 2021-08-20 12:26:37 -0700 | [diff] [blame] | 37 | from datetime import datetime |
| Joel Galenson | 0835244 | 2021-08-20 11:39:48 -0700 | [diff] [blame] | 38 | from pathlib import Path |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 39 | |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 40 | # Some tests requires specific options. Consider fixing the upstream crate |
| 41 | # before updating this dictionary. |
| 42 | TEST_OPTIONS = { |
| Joel Galenson | a0d4c5e | 2021-04-06 09:36:47 -0700 | [diff] [blame] | 43 | "ring_device_test_tests_digest_tests": [{"test-timeout": "600000"}], |
| 44 | "ring_device_test_src_lib": [{"test-timeout": "100000"}], |
| 45 | } |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 46 | |
| 47 | # Excluded tests. These tests will be ignored by this script. |
| 48 | TEST_EXCLUDE = [ |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 49 | "aidl_test_rust_client", |
| 50 | "aidl_test_rust_service" |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 51 | ] |
| 52 | |
| 53 | # Excluded modules. |
| 54 | EXCLUDE_PATHS = [ |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 55 | "//external/adhd", |
| 56 | "//external/crosvm", |
| 57 | "//external/libchromeos-rs", |
| 58 | "//external/vm_tools" |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 59 | ] |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 60 | |
| Thiébaud Weksteen | 5212f8a | 2021-06-10 08:18:32 +0200 | [diff] [blame] | 61 | |
| 62 | class UpdaterException(Exception): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 63 | """Exception generated by this script.""" |
| Thiébaud Weksteen | 5212f8a | 2021-06-10 08:18:32 +0200 | [diff] [blame] | 64 | |
| 65 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 66 | class Env(object): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 67 | """Env captures the execution environment. |
| 68 | |
| 69 | It ensures this script is executed within an AOSP repository. |
| 70 | |
| 71 | Attributes: |
| 72 | ANDROID_BUILD_TOP: A string representing the absolute path to the top |
| 73 | of the repository. |
| 74 | """ |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 75 | def __init__(self): |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 76 | try: |
| 77 | self.ANDROID_BUILD_TOP = os.environ['ANDROID_BUILD_TOP'] |
| Thiébaud Weksteen | 5212f8a | 2021-06-10 08:18:32 +0200 | [diff] [blame] | 78 | except KeyError: |
| 79 | raise UpdaterException('$ANDROID_BUILD_TOP is not defined; you ' |
| 80 | 'must first source build/envsetup.sh and ' |
| 81 | 'select a target.') |
| Thiébaud Weksteen | 5212f8a | 2021-06-10 08:18:32 +0200 | [diff] [blame] | 82 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 83 | |
| 84 | class Bazel(object): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 85 | """Bazel wrapper. |
| 86 | |
| 87 | The wrapper is used to call bazel queryview and generate the list of |
| 88 | reverse dependencies. |
| 89 | |
| 90 | Attributes: |
| 91 | path: The path to the bazel executable. |
| 92 | """ |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 93 | def __init__(self, env): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 94 | """Constructor. |
| 95 | |
| 96 | Note that the current directory is changed to ANDROID_BUILD_TOP. |
| 97 | |
| 98 | Args: |
| 99 | env: An instance of Env. |
| 100 | |
| 101 | Raises: |
| 102 | UpdaterException: an error occurred while calling soong_ui. |
| 103 | """ |
| Thiébaud Weksteen | 3e32afc | 2021-06-10 07:56:06 +0200 | [diff] [blame] | 104 | if platform.system() != 'Linux': |
| Thiébaud Weksteen | 5212f8a | 2021-06-10 08:18:32 +0200 | [diff] [blame] | 105 | raise UpdaterException('This script has only been tested on Linux.') |
| Thiébaud Weksteen | 3e32afc | 2021-06-10 07:56:06 +0200 | [diff] [blame] | 106 | self.path = os.path.join(env.ANDROID_BUILD_TOP, "tools", "bazel") |
| Thiébaud Weksteen | df132d6 | 2021-06-10 08:45:37 +0200 | [diff] [blame] | 107 | soong_ui = os.path.join(env.ANDROID_BUILD_TOP, "build", "soong", "soong_ui.bash") |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 108 | |
| 109 | # soong_ui requires to be at the root of the repository. |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 110 | os.chdir(env.ANDROID_BUILD_TOP) |
| Thiébaud Weksteen | df132d6 | 2021-06-10 08:45:37 +0200 | [diff] [blame] | 111 | print("Generating Bazel files...") |
| 112 | cmd = [soong_ui, "--make-mode", "GENERATE_BAZEL_FILES=1", "nothing"] |
| Jeff Vander Stoep | 1b24dc3 | 2021-02-03 18:52:42 +0100 | [diff] [blame] | 113 | try: |
| Thiébaud Weksteen | df132d6 | 2021-06-10 08:45:37 +0200 | [diff] [blame] | 114 | subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True) |
| 115 | except subprocess.CalledProcessError as e: |
| 116 | raise UpdaterException('Unable to generate bazel workspace: ' + e.output) |
| 117 | |
| 118 | print("Building Bazel Queryview. This can take a couple of minutes...") |
| 119 | cmd = [soong_ui, "--build-mode", "--all-modules", "--dir=.", "queryview"] |
| 120 | try: |
| 121 | subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True) |
| Jeff Vander Stoep | 1b24dc3 | 2021-02-03 18:52:42 +0100 | [diff] [blame] | 122 | except subprocess.CalledProcessError as e: |
| Thiébaud Weksteen | 5212f8a | 2021-06-10 08:18:32 +0200 | [diff] [blame] | 123 | raise UpdaterException('Unable to update TEST_MAPPING: ' + e.output) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 124 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 125 | def query_modules(self, path): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 126 | """Returns all modules for a given path.""" |
| Thiébaud Weksteen | 3e32afc | 2021-06-10 07:56:06 +0200 | [diff] [blame] | 127 | cmd = self.path + " query --config=queryview /" + path + ":all" |
| Thiébaud Weksteen | 76c4e23 | 2021-06-10 07:35:19 +0200 | [diff] [blame] | 128 | out = subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL, text=True).strip().split("\n") |
| 129 | modules = set() |
| 130 | for line in out: |
| 131 | # speed up by excluding unused modules. |
| 132 | if "windows_x86" in line: |
| 133 | continue |
| 134 | modules.add(line) |
| 135 | return modules |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 136 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 137 | def query_rdeps(self, module): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 138 | """Returns all reverse dependencies for a single module.""" |
| Thiébaud Weksteen | 3e32afc | 2021-06-10 07:56:06 +0200 | [diff] [blame] | 139 | cmd = (self.path + " query --config=queryview \'rdeps(//..., " + |
| Thiébaud Weksteen | 76c4e23 | 2021-06-10 07:35:19 +0200 | [diff] [blame] | 140 | module + ")\' --output=label_kind") |
| 141 | out = (subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL, text=True) |
| 142 | .strip().split("\n")) |
| 143 | if '' in out: |
| 144 | out.remove('') |
| 145 | return out |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 146 | |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 147 | def exclude_module(self, module): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 148 | for path in EXCLUDE_PATHS: |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 149 | if module.startswith(path): |
| 150 | return True |
| 151 | return False |
| 152 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 153 | def query_rdep_tests(self, modules): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 154 | """Returns all reverse dependency tests for modules in this package.""" |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 155 | rdep_tests = set() |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 156 | for module in modules: |
| 157 | for rdep in self.query_rdeps(module): |
| Thiébaud Weksteen | 2e532bb | 2021-06-10 09:01:34 +0200 | [diff] [blame] | 158 | rule_type, _, mod = rdep.split(" ") |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 159 | if rule_type == "rust_test_" or rule_type == "rust_test": |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 160 | if self.exclude_module(mod) == False: |
| 161 | rdep_tests.add(mod.split(":")[1].split("--")[0]) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 162 | return rdep_tests |
| 163 | |
| 164 | |
| Thiébaud Weksteen | 2e532bb | 2021-06-10 09:01:34 +0200 | [diff] [blame] | 165 | class Package(object): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 166 | """A Bazel package. |
| 167 | |
| 168 | Attributes: |
| 169 | dir: The absolute path to this package. |
| 170 | dir_rel: The relative path to this package. |
| 171 | rdep_tests: The list of computed reverse dependencies. |
| 172 | """ |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 173 | def __init__(self, path, env, bazel): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 174 | """Constructor. |
| 175 | |
| 176 | Note that the current directory is changed to the package location when |
| 177 | called. |
| 178 | |
| 179 | Args: |
| 180 | path: Path to the package. |
| 181 | env: An instance of Env. |
| 182 | bazel: An instance of Bazel. |
| 183 | |
| 184 | Raises: |
| 185 | UpdaterException: the package does not appear to belong to the |
| 186 | current repository. |
| 187 | """ |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 188 | self.dir = path |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 189 | try: |
| 190 | self.dir_rel = self.dir.split(env.ANDROID_BUILD_TOP)[1] |
| 191 | except IndexError: |
| 192 | raise UpdaterException('The path ' + self.dir + ' is not under ' + |
| 193 | env.ANDROID_BUILD_TOP + '; You must be in the ' |
| 194 | 'directory of a crate or pass its absolute path ' |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 195 | 'as the argument.') |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 196 | |
| 197 | # Move to the package_directory. |
| 198 | os.chdir(self.dir) |
| 199 | modules = bazel.query_modules(self.dir_rel) |
| Thiébaud Weksteen | 2e532bb | 2021-06-10 09:01:34 +0200 | [diff] [blame] | 200 | self.rdep_tests = bazel.query_rdep_tests(modules) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 201 | |
| 202 | def get_rdep_tests(self): |
| 203 | return self.rdep_tests |
| 204 | |
| 205 | |
| 206 | class TestMapping(object): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 207 | """A TEST_MAPPING file. |
| 208 | |
| 209 | Attributes: |
| 210 | package: The package associated with this TEST_MAPPING file. |
| 211 | """ |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 212 | def __init__(self, env, bazel, path): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 213 | """Constructor. |
| 214 | |
| 215 | Args: |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 216 | env: An instance of Env. |
| 217 | bazel: An instance of Bazel. |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 218 | path: The absolute path to the package. |
| 219 | """ |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 220 | self.package = Package(path, env, bazel) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 221 | |
| Thiébaud Weksteen | 2e532bb | 2021-06-10 09:01:34 +0200 | [diff] [blame] | 222 | def create(self): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 223 | """Generates the TEST_MAPPING file.""" |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 224 | tests = self.package.get_rdep_tests() |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 225 | if not bool(tests): |
| 226 | return |
| 227 | test_mapping = self.tests_to_mapping(tests) |
| 228 | self.write_test_mapping(test_mapping) |
| 229 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 230 | def tests_to_mapping(self, tests): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 231 | """Translate the test list into a dictionary.""" |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 232 | test_mapping = {"presubmit": []} |
| 233 | for test in tests: |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 234 | if test in TEST_EXCLUDE: |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 235 | continue |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 236 | if test in TEST_OPTIONS: |
| 237 | test_mapping["presubmit"].append({"name": test, "options": TEST_OPTIONS[test]}) |
| Jeff Vander Stoep | 0b0e24f | 2021-01-24 20:50:26 +0100 | [diff] [blame] | 238 | else: |
| 239 | test_mapping["presubmit"].append({"name": test}) |
| Joel Galenson | 4f9d11f | 2021-04-06 10:18:21 -0700 | [diff] [blame] | 240 | test_mapping["presubmit"] = sorted(test_mapping["presubmit"], key=lambda t: t["name"]) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 241 | return test_mapping |
| 242 | |
| 243 | def write_test_mapping(self, test_mapping): |
| Thiébaud Weksteen | 3604b75 | 2021-06-10 14:22:00 +0200 | [diff] [blame] | 244 | """Writes the TEST_MAPPING file.""" |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 245 | with open("TEST_MAPPING", "w") as json_file: |
| Jeff Vander Stoep | 1b24dc3 | 2021-02-03 18:52:42 +0100 | [diff] [blame] | 246 | json_file.write("// Generated by update_crate_tests.py for tests that depend on this crate.\n") |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 247 | json.dump(test_mapping, json_file, indent=2, separators=(',', ': '), sort_keys=True) |
| 248 | json_file.write("\n") |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 249 | print("TEST_MAPPING successfully updated for %s!" % self.package.dir_rel) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 250 | |
| Thiébaud Weksteen | fc485b2 | 2021-06-10 13:30:20 +0200 | [diff] [blame] | 251 | |
| Joel Galenson | 0835244 | 2021-08-20 11:39:48 -0700 | [diff] [blame] | 252 | def parse_args(): |
| 253 | parser = argparse.ArgumentParser('update_crate_tests') |
| Joel Galenson | 4a2a3a8 | 2021-08-20 12:26:37 -0700 | [diff] [blame] | 254 | parser.add_argument('paths', |
| 255 | nargs='*', |
| 256 | help='Absolute or relative paths of the projects as globs.') |
| 257 | parser.add_argument('--branch_and_commit', |
| 258 | action='store_true', |
| 259 | help='Starts a new branch and commit changes.') |
| 260 | parser.add_argument('--push_change', |
| 261 | action='store_true', |
| 262 | help='Pushes change to Gerrit.') |
| Joel Galenson | 0835244 | 2021-08-20 11:39:48 -0700 | [diff] [blame] | 263 | return parser.parse_args() |
| 264 | |
| 265 | |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 266 | def main(): |
| Joel Galenson | 0835244 | 2021-08-20 11:39:48 -0700 | [diff] [blame] | 267 | args = parse_args() |
| 268 | paths = args.paths if len(args.paths) > 0 else [os.getcwd()] |
| 269 | # We want to use glob to get all the paths, so we first convert to absolute. |
| 270 | paths = [Path(path).resolve() for path in paths] |
| 271 | paths = sorted([path for abs_path in paths |
| 272 | for path in glob.glob(str(abs_path))]) |
| 273 | |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 274 | env = Env() |
| 275 | bazel = Bazel(env) |
| 276 | for path in paths: |
| 277 | try: |
| 278 | test_mapping = TestMapping(env, bazel, path) |
| Joel Galenson | 4a2a3a8 | 2021-08-20 12:26:37 -0700 | [diff] [blame] | 279 | test_mapping.create() |
| 280 | changed = (subprocess.call(['git', 'diff', '--quiet']) == 1) |
| Joel Galenson | bdf3ab4 | 2021-08-30 08:57:18 -0700 | [diff] [blame^] | 281 | untracked = (os.path.isfile('TEST_MAPPING') and |
| 282 | (subprocess.run(['git', 'ls-files', '--error-unmatch', 'TEST_MAPPING'], |
| 283 | stderr=subprocess.DEVNULL, |
| 284 | stdout=subprocess.DEVNULL).returncode == 1)) |
| 285 | if args.branch_and_commit and (changed or untracked): |
| Joel Galenson | 4a2a3a8 | 2021-08-20 12:26:37 -0700 | [diff] [blame] | 286 | subprocess.check_output(['repo', 'start', |
| 287 | 'tmp_auto_test_mapping', '.']) |
| 288 | subprocess.check_output(['git', 'add', 'TEST_MAPPING']) |
| 289 | subprocess.check_output(['git', 'commit', '-m', |
| 290 | 'Update TEST_MAPPING\n\nTest: None']) |
| Joel Galenson | bdf3ab4 | 2021-08-30 08:57:18 -0700 | [diff] [blame^] | 291 | if args.push_change and (changed or untracked): |
| Joel Galenson | 4a2a3a8 | 2021-08-20 12:26:37 -0700 | [diff] [blame] | 292 | date = datetime.today().strftime('%m-%d') |
| 293 | subprocess.check_output(['git', 'push', 'aosp', 'HEAD:refs/for/master', |
| 294 | '-o', 'topic=test-mapping-%s' % date]) |
| 295 | except (UpdaterException, subprocess.CalledProcessError) as err: |
| Joel Galenson | 1779104 | 2021-06-17 14:59:15 -0700 | [diff] [blame] | 296 | sys.exit("Error: " + str(err)) |
| Jeff Vander Stoep | cec8bac | 2021-01-15 14:15:37 +0100 | [diff] [blame] | 297 | |
| 298 | if __name__ == '__main__': |
| 299 | main() |