Skip to content

Commit

Permalink
Add support for adding back tests (#2017)
Browse files Browse the repository at this point in the history
This would enable the following use case:
```
    test_targets:
      - "//src/test/..."
      - "-//src/test/shell/.."
      - "+//src/test/shell/apple/.."
```
so that all shell tests are excluded but the ones for apple
  • Loading branch information
meteorcloudy authored Aug 6, 2024
1 parent 4bfd1ad commit 68193b3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions buildkite/bazelci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 68193b3

Please sign in to comment.