@@ -198,13 +198,14 @@ func (r *Runner) runTestPackage(packageName string) (string, bool, error) {
198198 return tmpFile .Name (), true , nil // Test succeeded
199199}
200200
201- // runCmd is a helper that runs the user-supplied command once, captures its JSON output,
202- // and returns (tempFilePath, passed, error) .
203- func (r * Runner ) runCmd (testCmd []string , runIndex int ) (string , bool , error ) {
201+ // runCmd runs the user-supplied command once, captures its JSON output,
202+ // and returns the temp file path, whether the test passed, and an error if any .
203+ func (r * Runner ) runCmd (testCmd []string , runIndex int ) (tempFilePath string , passed bool , err error ) {
204204 // Create temp file for JSON output
205205 tmpFile , err := os .CreateTemp ("" , fmt .Sprintf ("test-output-cmd-run%d-*.json" , runIndex + 1 ))
206206 if err != nil {
207- return "" , false , fmt .Errorf ("failed to create temp file: %w" , err )
207+ err = fmt .Errorf ("failed to create temp file: %w" , err )
208+ return
208209 }
209210 defer tmpFile .Close ()
210211
@@ -232,23 +233,28 @@ func (r *Runner) runCmd(testCmd []string, runIndex int) (string, bool, error) {
232233
233234 err = cmd .Run ()
234235
236+ tempFilePath = tmpFile .Name ()
237+
235238 // Determine pass/fail from exit code
236239 type exitCoder interface {
237240 ExitCode () int
238241 }
239242 var ec exitCoder
240243 if errors .As (err , & ec ) {
241244 // Non-zero exit code => test failure
242- if ec .ExitCode () != 0 {
243- return tmpFile . Name (), false , nil
244- }
245+ passed = ec .ExitCode () == 0
246+ err = nil // Clear error since we handled it
247+ return
245248 } else if err != nil {
246249 // Some other error that doesn't implement ExitCode() => real error
247- return "" , false , fmt .Errorf ("error running test command: %w" , err )
250+ tempFilePath = ""
251+ err = fmt .Errorf ("error running test command: %w" , err )
252+ return
248253 }
249254
250- // Otherwise, assume success
251- return tmpFile .Name (), true , nil
255+ // Otherwise, test passed
256+ passed = true
257+ return
252258}
253259
254260type entry struct {
0 commit comments