mirror of https://github.com/go-python/gopy.git
gopy: add diff output when tests fail
Change-Id: I31c586aedb81a43676fd3e323b7adff82903ac1e
This commit is contained in:
parent
7852de8d4b
commit
577ca00d4b
26
main_test.go
26
main_test.go
|
@ -68,9 +68,33 @@ func testPkg(t *testing.T, table pkg) {
|
|||
}
|
||||
|
||||
if !reflect.DeepEqual(string(buf.Bytes()), string(table.want)) {
|
||||
t.Fatalf("[%s]: error running python module:\nwant:\n%s\n\ngot:\n%s\n",
|
||||
diffTxt := ""
|
||||
diffBin, diffErr := exec.LookPath("diff")
|
||||
if diffErr == nil {
|
||||
wantFile, wantErr := os.Create(filepath.Join(workdir, "want.txt"))
|
||||
if wantErr == nil {
|
||||
wantFile.Write(table.want)
|
||||
wantFile.Close()
|
||||
}
|
||||
gotFile, gotErr := os.Create(filepath.Join(workdir, "got.txt"))
|
||||
if gotErr == nil {
|
||||
gotFile.Write(buf.Bytes())
|
||||
gotFile.Close()
|
||||
}
|
||||
if gotErr == nil && wantErr == nil {
|
||||
cmd = exec.Command(diffBin, "-urN",
|
||||
wantFile.Name(),
|
||||
gotFile.Name(),
|
||||
)
|
||||
diff, _ := cmd.CombinedOutput()
|
||||
diffTxt = string(diff) + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
t.Fatalf("[%s]: error running python module:\nwant:\n%s\n\ngot:\n%s\n%s",
|
||||
table.path,
|
||||
string(table.want), string(buf.Bytes()),
|
||||
diffTxt,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue