Show build details when a build fails

Closes #4
This commit is contained in:
Max Claus Nunes 2018-09-08 10:35:29 -03:00
parent a2082c3041
commit 7f5268751f
2 changed files with 7 additions and 2 deletions

View File

@ -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() {

View File

@ -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) {