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

internal/civisibility: fixes the test parent status when the auto-retry feature ended up with a failed test and then a successful test. #2910

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,11 @@ func applyAdditionalFeaturesToTestFunc(f func(*testing.T)) func(*testing.T) {
tCommonPrivates := getTestPrivateFields(t)
tCommonPrivates.SetFailed(ptrToLocalT.Failed())
tCommonPrivates.SetSkipped(ptrToLocalT.Skipped())
tParentCommonPrivates.SetFailed(ptrToLocalT.Failed())

// Only change the parent status to failing if the current test failed
if ptrToLocalT.Failed() {
tParentCommonPrivates.SetFailed(ptrToLocalT.Failed())
}
break
}
}
Expand Down
13 changes: 9 additions & 4 deletions internal/civisibility/integrations/gotesting/testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,18 @@ func TestMain(m *testing.M) {

// execute the tests, because we are expecting some tests to fail and check the assertion later
// we don't store the exit code from the test runner
RunM(m)
exitCode := RunM(m)
if exitCode != 1 {
panic("expected the exit code to be 1. We have a failing test on purpose.")
}

// get all finished spans
finishedSpans := mTracer.FinishedSpans()

// 1 session span
// 1 module span
// 2 suite span (testing_test.go and reflections_test.go)
// 5 tests spans from testing_test.go
// 6 tests spans from testing_test.go
// 7 sub stest spans from testing_test.go
// 1 TestRetryWithPanic + 3 retry tests from testing_test.go
// 1 TestRetryWithFail + 3 retry tests from testing_test.go
Expand All @@ -89,7 +92,7 @@ func TestMain(m *testing.M) {
// 5 tests from reflections_test.go
// 2 benchmark spans (optional - require the -bench option)
fmt.Printf("Number of spans received: %d\n", len(finishedSpans))
if len(finishedSpans) < 36 {
if len(finishedSpans) < 37 {
panic("expected at least 36 finished spans, got " + strconv.Itoa(len(finishedSpans)))
}

Expand Down Expand Up @@ -117,7 +120,7 @@ func TestMain(m *testing.M) {
testSpans := getSpansWithType(finishedSpans, constants.SpanTypeTest)
fmt.Printf("Number of tests received: %d\n", len(testSpans))
showResourcesNameFromSpans(testSpans)
if len(testSpans) != 36 {
if len(testSpans) != 37 {
panic("expected exactly 36 test spans, got " + strconv.Itoa(len(testSpans)))
tonyredondo marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -311,6 +314,8 @@ func TestRetryAlwaysFail(t *testing.T) {
t.Fatal("Always fail")
}

func TestNormalPassingAfterRetryAlwaysFail(t *testing.T) {}
tonyredondo marked this conversation as resolved.
Show resolved Hide resolved

// BenchmarkFirst demonstrates benchmark instrumentation with sub-benchmarks.
func BenchmarkFirst(gb *testing.B) {

Expand Down
Loading