Skip to content

Commit 7f52687

Browse files
committed
Show build details when a build fails
Closes #4
1 parent a2082c3 commit 7f52687

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (b *builder) Build() error {
5656

5757
output, err := command.CombinedOutput()
5858
if err != nil {
59-
return err
59+
return fmt.Errorf("build failed with %v\n%s", err, output)
6060
}
6161

6262
if !command.ProcessState.Success() {

builder_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ func TestBuilderFailureBuild(t *testing.T) {
3838
t.Fatalf("couldn't get current working directory: %v", err)
3939
}
4040

41+
absPathBuild := filepath.Join(wd, dir)
42+
4143
b := NewBuilder(dir, bin, wd, bArgs)
4244
err = b.Build()
4345
assert.NotNil(t, err, "build error")
44-
assert.Equal(t, err.Error(), "exit status 2")
46+
assert.Equal(t, err.Error(), "build failed with exit status 2\n"+
47+
"# _"+absPathBuild+"\n"+
48+
"./main.go:4:6: func main must have no arguments and no return values\n"+
49+
"./main.go:5:1: missing return at end of function\n")
4550
}
4651

4752
func TestBuilderDefaultBinName(t *testing.T) {

0 commit comments

Comments
 (0)