Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tools/testmask/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ var commonTriggerPatterns = []string{
"tools/task/",
}

// ignoredFiles lists files that never affect test results.
var ignoredFiles = []string{
".github/CODEOWNERS",
}

type targetMapping struct {
prefixes []string
target string
Expand Down Expand Up @@ -107,6 +112,10 @@ func GetTargets(files []string, mappings []targetMapping) []string {
unmatchedFiles := []string{}

for _, file := range files {
if slices.Contains(ignoredFiles, file) {
continue
}

matched := false
for _, mapping := range mappings {
for _, prefix := range mapping.prefixes {
Expand All @@ -127,7 +136,10 @@ func GetTargets(files []string, mappings []targetMapping) []string {
}

if len(targetSet) == 0 {
return []string{"test"}
if len(files) == 0 {
return []string{"test"}
}
return []string{}
}

return slices.Sorted(maps.Keys(targetSet))
Expand Down
15 changes: 15 additions & 0 deletions tools/testmask/targets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ func TestGetTargets(t *testing.T) {
files: []string{},
targets: []string{"test"},
},
{
name: "codeowners_only",
files: []string{
".github/CODEOWNERS",
},
targets: []string{},
},
{
name: "codeowners_with_other_files",
files: []string{
".github/CODEOWNERS",
"bundle/config.go",
},
targets: []string{"test"},
},
}

for _, tt := range tests {
Expand Down
Loading