Skip to content

Commit

Permalink
Merge pull request #377 from ddworken/pr
Browse files Browse the repository at this point in the history
Update gotestsum retries to properly filter out parents when there is a a missing gap in the parent tree
  • Loading branch information
dnephin committed Oct 24, 2023
2 parents 3002ceb + bfb4889 commit e5e4f7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,9 @@ func FilterFailedUnique(tcs []TestCase) []TestCase {
if _, exists := parents[tc.Package]; !exists {
parents[tc.Package] = make(map[string]bool)
}
if parent := tc.Test.Parent(); parent != "" {
parents[tc.Package][parent] = true

for p := tc.Test.Parent(); p != ""; p = TestName(p).Parent() {
parents[tc.Package][p] = true
}
if _, exists := parents[tc.Package][tc.Test.Name()]; exists {
continue // tc is a parent of a failing subtest
Expand Down
17 changes: 17 additions & 0 deletions testjson/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,20 @@ func TestFilterFailedUnique_MultipleNested(t *testing.T) {
cmpTestCase := cmp.AllowUnexported(TestCase{})
assert.DeepEqual(t, expected, actual, cmpTestCase)
}

func TestFilterFailedUnique_NestedWithGaps(t *testing.T) {
input := []TestCase{
{ID: 1, Package: "pkg", Test: "TestParent/foo/bar/baz"},
{ID: 2, Package: "pkg", Test: "TestParent"},
{ID: 3, Package: "pkg", Test: "TestParent1/foo/bar"},
{ID: 4, Package: "pkg", Test: "TestParent1"},
}
actual := FilterFailedUnique(input)

expected := []TestCase{
{ID: 1, Package: "pkg", Test: "TestParent/foo/bar/baz"},
{ID: 3, Package: "pkg", Test: "TestParent1/foo/bar"},
}
cmpTestCase := cmp.AllowUnexported(TestCase{})
assert.DeepEqual(t, expected, actual, cmpTestCase)
}

0 comments on commit e5e4f7e

Please sign in to comment.