From 8ea02d6b890c54cbe2d5e78cefa626bc7d53571a Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 5 Aug 2026 03:25:16 -0700 Subject: [PATCH] Fix format string handling for collection_subject.contains_none_of. If a format string was specified it would throw an error due to incorrectly handling the list type input. PiperOrigin-RevId: 959549179 --- lib/private/collection_subject.bzl | 3 ++- tests/truth_tests.bzl | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/private/collection_subject.bzl b/lib/private/collection_subject.bzl index c804e18..67d7e80 100644 --- a/lib/private/collection_subject.bzl +++ b/lib/private/collection_subject.bzl @@ -268,8 +268,9 @@ def _collection_subject_contains_none_of(self, values): self: implicitly added values: ([`collection`]) values of which none of are allowed to exist. """ + values = to_list(values) if self.format: - values = self.meta.format_str(values) + values = [self.meta.format_str(v) for v in values] check_contains_none_of( collection = self.actual, none_of = values, diff --git a/tests/truth_tests.bzl b/tests/truth_tests.bzl index 9b5e654..2984344 100644 --- a/tests/truth_tests.bzl +++ b/tests/truth_tests.bzl @@ -90,6 +90,23 @@ def _action_subject_test(env, target): msg = "check argv success", ) + subject.argv().contains_none_of([ + "arg1", + "arg3", + "{bindir}/{package}/input.gen.txt", + ]) + _assert_failure( + fake_env, + [ + "expected not to contain any of", + "but 2 found", + "arg1", + "input.gen.txt", + ], + env = env, + msg = "check contains_none_of failure", + ) + subject.contains_flag_values([ ("--missingflag", "whatever"), ("--arg1flag", "wrongvalue"),