diff --git a/mantle/kola/harness.go b/mantle/kola/harness.go index f5b4e97b7b..d976595c7d 100644 --- a/mantle/kola/harness.go +++ b/mantle/kola/harness.go @@ -872,13 +872,27 @@ func runProvidedTests(testsBank map[string]*register.Test, patterns []string, mu newOutputDir := filepath.Join(outputDir, "rerun") fmt.Printf("\n\n======== Re-running failed tests (flake detection) ========\n\n") reRunErr := runProvidedTests(testsToRerun, []string{"*"}, multiply, false, rerunSuccessTags, pltfrm, newOutputDir) - if reRunErr == nil && allTestsAllowRerunSuccess(testsToRerun, rerunSuccessTags) { + // Four possible outcomes from the rerun: + // 1. reRunErr == nil && allTestsAllowRerunSuccess == true: + // Tests passed on rerun AND have the required tags to allow rerun success. + // Reset to success (runErr = nil). + // 2. reRunErr != nil && allTestsAllowRerunSuccess == false: + // Tests failed on rerun and don't have tags. Use the rerun error (runErr = reRunErr). + // 3. reRunErr == nil && allTestsAllowRerunSuccess == false: + // Tests passed on rerun BUT don't have the required tags to allow rerun success. + // Keep the original error (don't modify runErr) - the initial failure stands. + // 4. reRunErr != nil && allTestsAllowRerunSuccess == true: + // Tests failed on rerun even though they have allow-rerun-success tags. + // Use the rerun error (runErr = reRunErr) - tags only matter when rerun passes. + if reRunErr != nil { + // Scenarios 2 & 4: Rerun failed - use the rerun error regardless of tags + runErr = reRunErr + } else if allTestsAllowRerunSuccess(testsToRerun, rerunSuccessTags) { + // Scenario 1: Rerun passed AND tests have tags to allow rerun success runErr = nil // reset to success since all tests allowed rerun success numFailedTests = 0 // zero out the tally of failed tests - } else { - runErr = reRunErr } - + // else: Scenario 3 - keep original runErr (test passed on rerun but doesn't allow rerun success) } // Return ErrWarnOnTestFail when ONLY tests with warn:true feature failed