Skip to content

Commit 8cdf5d2

Browse files
committed
Enhance error handling in transformTestOutputFiles to log original file contents on transformation failure
1 parent b08cab0 commit 8cdf5d2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/flakeguard/runner/runner.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,16 @@ func (r *Runner) transformTestOutputFiles(filePaths []string) error {
604604
inFile.Close()
605605
outFile.Close()
606606
if err != nil {
607+
// Transformation failed; read & log the original file’s contents.
608+
raw, readErr := os.ReadFile(origPath)
609+
if readErr != nil {
610+
return fmt.Errorf(
611+
"failed to transform file %s: %v (also failed reading original file: %v)",
612+
origPath, err, readErr,
613+
)
614+
}
615+
log.Printf("Original test file %s content:\n%s\n", origPath, string(raw))
616+
607617
return fmt.Errorf("failed to transform output file %s: %v", origPath, err)
608618
}
609619
// Use the transformed file path.

0 commit comments

Comments
 (0)