From 97318c100a1aaf7a4c848f956e12fb700271306d Mon Sep 17 00:00:00 2001 From: "John Howard (VM)" Date: Fri, 10 Mar 2017 15:21:51 -0800 Subject: [PATCH] Fix stringer in Result (pkg\testutil\cmd) Signed-off-by: John Howard (VM) Upstream-commit: f577131d3bc49860f615c458e44fc035b3708415 Component: engine --- components/engine/pkg/testutil/cmd/command.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/components/engine/pkg/testutil/cmd/command.go b/components/engine/pkg/testutil/cmd/command.go index 3086574f4a..4d72f22957 100644 --- a/components/engine/pkg/testutil/cmd/command.go +++ b/components/engine/pkg/testutil/cmd/command.go @@ -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,