From 029a195cb7910511261f0024cd3cfe558ff3ac7a Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Thu, 5 May 2022 15:32:58 +0200 Subject: [PATCH] pytest: store output of tested script This CL stores the output of a failing script for easy human comparison Signed-off-by: Sebastien Binet --- pytest/pytest.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pytest/pytest.go b/pytest/pytest.go index 232f7525..7b3c7cba 100644 --- a/pytest/pytest.go +++ b/pytest/pytest.go @@ -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() @@ -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) } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy