1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix stringer in Result (pkg\testutil\cmd)

Signed-off-by: John Howard (VM) <jhoward@ntdev.microsoft.com>
This commit is contained in:
John Howard (VM) 2017-03-10 15:21:51 -08:00
parent b6c5b4730b
commit f577131d3b

View file

@ -59,9 +59,12 @@ func (r *Result) Assert(t testingT, exp Expected) {
if err == nil {
return
}
_, file, line, _ := runtime.Caller(1)
t.Fatalf("at %s:%d\n%s", filepath.Base(file), line, err.Error())
_, file, line, ok := runtime.Caller(1)
if ok {
t.Fatalf("at %s:%d - %s", filepath.Base(file), line, err.Error())
} else {
t.Fatalf("(no file/line info) - %s", err.Error())
}
}
// Compare returns a formatted error with the command, stdout, stderr, exit
@ -123,10 +126,11 @@ func (r *Result) String() string {
}
return fmt.Sprintf(`
Command: %s
ExitCode: %d%s, Error: %s
Stdout: %v
Stderr: %v
Command: %s
ExitCode: %d%s
Error: %v
Stdout: %v
Stderr: %v
`,
strings.Join(r.Cmd.Args, " "),
r.ExitCode,