Skip to content

Commit 7419dd2

Browse files
fix(agent/agentcontainers): fix devcontainer integration tests
1 parent e4dc2d9 commit 7419dd2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

agent/agentcontainers/api.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ func WithContainerCLI(ccli ContainerCLI) Option {
161161

162162
// WithContainerLabelIncludeFilter sets a label filter for containers.
163163
// This option can be given multiple times to filter by multiple labels.
164-
// The behavior is such that only containers matching one or more of the
165-
// provided labels will be included.
164+
// The behavior is such that only containers matching all of the provided
165+
// labels will be included.
166166
func WithContainerLabelIncludeFilter(label, value string) Option {
167167
return func(api *API) {
168168
api.containerLabelIncludeFilter[label] = value
@@ -927,13 +927,18 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code
927927
slog.F("config_file", configFile),
928928
)
929929

930+
// If we haven't set any include filters, we should explicitly ignore test devcontainers.
931+
if len(api.containerLabelIncludeFilter) == 0 && container.Labels[DevcontainerIsTestRunLabel] == "true" {
932+
continue
933+
}
934+
930935
// Filter out devcontainer tests, unless explicitly set in include filters.
931-
if len(api.containerLabelIncludeFilter) > 0 || container.Labels[DevcontainerIsTestRunLabel] == "true" {
932-
var ok bool
936+
if len(api.containerLabelIncludeFilter) > 0 {
937+
ok := true
933938
for label, value := range api.containerLabelIncludeFilter {
934-
if v, found := container.Labels[label]; found && v == value {
935-
ok = true
936-
}
939+
v, found := container.Labels[label]
940+
941+
ok = ok && (found && v == value)
937942
}
938943
// Verbose debug logging is fine here since typically filters
939944
// are only used in development or testing environments.

0 commit comments

Comments
 (0)