From 7f5268751ff04ad898fb96cb1219c1b3a7031db0 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sat, 8 Sep 2018 10:35:29 -0300 Subject: [PATCH] Show build details when a build fails Closes #4 --- builder.go | 2 +- builder_test.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/builder.go b/builder.go index d46b27a..e5e2be7 100644 --- a/builder.go +++ b/builder.go @@ -56,7 +56,7 @@ func (b *builder) Build() error { output, err := command.CombinedOutput() if err != nil { - return err + return fmt.Errorf("build failed with %v\n%s", err, output) } if !command.ProcessState.Success() { diff --git a/builder_test.go b/builder_test.go index c7e6c5a..4abcfeb 100644 --- a/builder_test.go +++ b/builder_test.go @@ -38,10 +38,15 @@ func TestBuilderFailureBuild(t *testing.T) { t.Fatalf("couldn't get current working directory: %v", err) } + absPathBuild := filepath.Join(wd, dir) + b := NewBuilder(dir, bin, wd, bArgs) err = b.Build() assert.NotNil(t, err, "build error") - assert.Equal(t, err.Error(), "exit status 2") + assert.Equal(t, err.Error(), "build failed with exit status 2\n"+ + "# _"+absPathBuild+"\n"+ + "./main.go:4:6: func main must have no arguments and no return values\n"+ + "./main.go:5:1: missing return at end of function\n") } func TestBuilderDefaultBinName(t *testing.T) {