Skip to content
Merged
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
6 changes: 5 additions & 1 deletion pytest/pytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ func RunBenchmarks(b *testing.B, testDir string) {
// RunScript runs the provided path to a script.
// RunScript captures the stdout and stderr while executing the script
// and compares it to a golden file:
// RunScript("./testdata/foo.py")
//
// RunScript("./testdata/foo.py")
//
// will compare the output with "./testdata/foo_golden.txt".
func RunScript(t *testing.T, fname string) {
opts := py.DefaultContextOpts()
Expand Down Expand Up @@ -180,6 +182,8 @@ func RunScript(t *testing.T, fname string) {

diff := cmp.Diff(string(want), string(got))
if !bytes.Equal(got, want) {
out := fname[:len(fname)-len(".py")] + ".txt"
_ = os.WriteFile(out, got, 0644)
t.Fatalf("output differ: -- (-ref +got)\n%s", diff)
}
}