Skip to content
Open
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
22 changes: 18 additions & 4 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +887 to +895
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When Scenario 3 occurs (tests pass on rerun but lack the necessary tags), the output might be confusing to users because they will see a PASS for the rerun followed by an overall FAIL for the test suite. Adding an explicit log message here would clarify why the original failure is being preserved despite the successful rerun.

		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 {
			// Scenario 3: Rerun passed but tags don't allow success.
			fmt.Printf("Tests passed on rerun but lack tags to allow rerun success; original failure stands.\n")
		}

}

// Return ErrWarnOnTestFail when ONLY tests with warn:true feature failed
Expand Down