Skip to content

Commit

Permalink
fix: testing-isolation do not force run all if no packages were found (
Browse files Browse the repository at this point in the history
…#3939)

* fix: testing-isolation do not force run all if no packages were found

* add test case

---------

Co-authored-by: Jennifer Davis <[email protected]>
  • Loading branch information
davidcavazos and iennae authored Dec 24, 2024
1 parent 1504bdc commit d7fb7e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions .github/cloud-samples-tools/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ func (c *Config) Changed(log io.Writer, diffs []string) []string {
changedUnique[pkg] = true
}

if len(changedUnique) == 0 {
return []string{"."}
}

changed := make([]string, 0, len(changedUnique))
for pkg := range changedUnique {
if slices.Contains(c.ExcludePackages, pkg) {
Expand Down
5 changes: 5 additions & 0 deletions .github/cloud-samples-tools/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func TestChanged(t *testing.T) {
config := c.Config{
PackageFile: []string{"package.json"},
Match: []string{"*"},
Ignore: []string{"ignored.txt"},
ExcludePackages: []string{filepath.Join("testdata", "excluded")},
}

Expand All @@ -180,6 +181,10 @@ func TestChanged(t *testing.T) {
diffs: []string{filepath.Join("testdata", "file.txt")},
expected: []string{"."},
},
{ // Ignored files should not trigger tests.
diffs: []string{filepath.Join("testdata", "ignored.txt")},
expected: []string{},
},
{ // Single affected package.
diffs: []string{filepath.Join("testdata", "my-package", "file.txt")},
expected: []string{filepath.Join("testdata", "my-package")},
Expand Down

0 comments on commit d7fb7e2

Please sign in to comment.