Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gotestsum retries to properly filter out parents when there is a a missing gap in the parent tree #377

Merged
merged 2 commits into from
Oct 24, 2023
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
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)
}