From de0f06a41943e01e05eb055361a09a11df0a84b9 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Tue, 6 Aug 2024 18:10:23 +0200 Subject: [PATCH] Add support for adding back tests --- buildkite/bazelci.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py index 83f5040367..21ed7a5912 100755 --- a/buildkite/bazelci.py +++ b/buildkite/bazelci.py @@ -2318,7 +2318,7 @@ def expand_test_target_patterns(bazel_binary, test_targets, test_flags): def get_test_query(test_targets, test_flags): - included_targets, excluded_targets = partition_list(test_targets) + included_targets, excluded_targets, added_back = partition_list(test_targets) def FormatTargetList(targets): return " ".join("'{}'".format(t) for t in targets) @@ -2328,6 +2328,9 @@ def FormatTargetList(targets): if excluded_targets: query += " except tests(set({}))".format(FormatTargetList(excluded_targets)) + if added_back: + query += " union tests(set({}))".format(FormatTargetList(added_back)) + included_tags, excluded_tags = get_test_tags(test_flags) for t in excluded_tags: @@ -2567,14 +2570,16 @@ def run_bazel_diff(bazel_diff_path, old_workspace_dir, new_workspace_dir, bazel_ def partition_list(items): - included, excluded = [], [] + included, excluded, added_back = [], [], [] for i in items: if i.startswith("-"): excluded.append(i[1:]) + elif i.startswith("+"): + added_back.append(i[1:]) else: included.append(i) - return included, excluded + return included, excluded, added_back def get_targets_for_shard(test_targets, shard_id, shard_count):