@@ -313,6 +313,31 @@ func handleReruns(exitHandler *summaryAndExit, testRunner *runner.Runner, mainRe
313313 return // Exit successfully
314314 }
315315
316+ // Check if we should skip reruns due to --test-cmd and command-line-arguments
317+ if len (cfg .TestCmds ) > 0 {
318+ foundCommandLineArgs := false
319+ for _ , test := range failedTests {
320+ if test .TestPackage == "command-line-arguments" {
321+ foundCommandLineArgs = true
322+ break
323+ }
324+ }
325+
326+ if foundCommandLineArgs {
327+ warningMsg := "WARNING: Skipping all reruns because 'go test <file.go>' was detected within --test-cmd. " +
328+ "Flakeguard cannot reliably rerun these tests as it loses the original directory context. " +
329+ "Results are based on the initial run only. To enable reruns, use 'go test . -run TestPattern' instead of 'go test <file.go>' within your --test-cmd."
330+ log .Warn ().Msg (warningMsg )
331+ // Use explicit newlines
332+ fmt .Fprint (& exitHandler .buffer , "\n Failed Tests On The First Run:\n \n " )
333+ reports .PrintTestResultsTable (& exitHandler .buffer , failedTests , false , false , true , false , false , false )
334+ fmt .Fprintf (& exitHandler .buffer , "\n \n %s\n " , warningMsg ) // Print the detailed warning
335+ // Evaluate the initial run results as if reruns were disabled
336+ handleNoReruns (exitHandler , mainReport , cfg )
337+ return // Exit after handling based on the initial run
338+ }
339+ }
340+
316341 // Use explicit newlines
317342 fmt .Fprint (& exitHandler .buffer , "\n Failed Tests On The First Run:\n \n " )
318343 reports .PrintTestResultsTable (& exitHandler .buffer , failedTests , false , false , true , false , false , false )
@@ -330,6 +355,7 @@ func handleReruns(exitHandler *summaryAndExit, testRunner *runner.Runner, mainRe
330355 exitHandler .logErrorAndExit (err , "Error rerunning failed tests" )
331356 }
332357
358+ // --- Process Rerun Results ---
333359 rerunReport , err := reports .NewTestReport (rerunResults ,
334360 reports .WithGoProject (goProject ),
335361 reports .WithCodeOwnersPath (cfg .CodeownersPath ),
0 commit comments