diff --git a/scripts/update_crate_tests.py b/scripts/update_crate_tests.py index 0e2437193..bfcc4cf92 100755 --- a/scripts/update_crate_tests.py +++ b/scripts/update_crate_tests.py @@ -20,6 +20,18 @@ import platform import subprocess import sys +test_options = {"ring_device_test_tests_digest_tests": [{"test-timeout": "600000"}]} +test_exclude = [ + "aidl_test_rust_client", + "aidl_test_rust_service" + ] +exclude_paths = [ + "//external/adhd", + "//external/crosvm", + "//external/libchromeos-rs", + "//external/vm_tools" + ] + class Env(object): def __init__(self): try: @@ -61,29 +73,30 @@ class Bazel(object): # Return all reverse dependencies for a single module. def query_rdeps(self, module): with open(os.devnull, 'wb') as DEVNULL: - # Bazel queryview special-cases external/ so we need two - # separate queries to collect all the reverse dependencies. cmd = (self.path() + " query --config=queryview \'rdeps(//..., " + module + ")\' --output=label_kind") out = (subprocess.check_output(cmd, shell=True, stderr=DEVNULL, text=True) .strip().split("\n")) - cmd = (self.path() + " query --config=queryview --universe_scope=//external/... " + - "--order_output=no \"allrdeps(" + module + ")\" --output=label_kind") - out += (subprocess.check_output(cmd, shell=True, stderr=DEVNULL, text=True) - .strip().split("\n")) if '' in out: out.remove('') return out + def exclude_module(self, module): + for path in exclude_paths: + if module.startswith(path): + return True + return False + # Return all reverse dependency tests for modules in this package. def query_rdep_tests(self, modules): rdep_tests = set() print("Querying tests that depend on this crate for TEST_MAPPING. This can take a couple of minutes...") for module in modules: for rdep in self.query_rdeps(module): - rule_type, tmp, module = rdep.split(" ") + rule_type, tmp, mod = rdep.split(" ") if rule_type == "rust_test_" or rule_type == "rust_test": - rdep_tests.add(module.split(":")[1].split("--")[0]) + if self.exclude_module(mod) == False: + rdep_tests.add(mod.split(":")[1].split("--")[0]) return rdep_tests @@ -118,7 +131,12 @@ class TestMapping(object): def tests_to_mapping(self, tests): test_mapping = {"presubmit": []} for test in tests: - test_mapping["presubmit"].append({"name": test}) + if test in test_exclude: + continue + if test in test_options: + test_mapping["presubmit"].append({"name": test, "options": test_options[test]}) + else: + test_mapping["presubmit"].append({"name": test}) return test_mapping def write_test_mapping(self, test_mapping):