Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/leeway/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func (p *Package) buildDependencies(buildctx *buildContext) error {
return g.Wait()
}

func (p *Package) build(buildctx *buildContext) error {
func (p *Package) build(buildctx *buildContext) (err error) {
// Try to obtain lock for building this package
doBuild := buildctx.ObtainBuildLock(p)
if !doBuild {
Expand Down Expand Up @@ -663,7 +663,6 @@ func (p *Package) build(buildctx *buildContext) error {
buildctx.Reporter.PackageBuildStarted(p)

// Ensure we notify reporter when build finishes
var err error
defer func() {
pkgRep.Error = err
buildctx.Reporter.PackageBuildFinished(p, pkgRep)
Expand Down
2 changes: 1 addition & 1 deletion pkg/leeway/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (r *ConsoleReporter) PackageBuildFinished(pkg *Package, rep *PackageBuildRe
if rep.TestCoverageAvailable {
coverage = color.Sprintf("<fg=yellow>test coverage: %d%%</> <gray>(%d of %d functions have tests)</>\n", rep.TestCoveragePercentage, rep.FunctionsWithTest, rep.FunctionsWithTest+rep.FunctionsWithoutTest)
}
msg = color.Sprintf("%s<green>package build succeded</> <gray>(%.2fs)%s</>\n", coverage, dur.Seconds(), phaseDurStr)
msg = color.Sprintf("%s<green>package build succeeded</> <gray>(%.2fs)%s</>\n", coverage, dur.Seconds(), phaseDurStr)
}
//nolint:errcheck
io.WriteString(out, msg)
Expand Down
20 changes: 18 additions & 2 deletions pkg/leeway/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package leeway

import (
"bytes"
"errors"
"testing"
"time"

Expand Down Expand Up @@ -64,7 +65,7 @@ func TestConsoleReporter(t *testing.T) {
},
Expect: Expectation{
Output: `[test:test] build started (version unknown)
[test:test] package build succeded (5.00s) [prep: 1.0s | pull: 1.0s | lint: 1.0s | test: 1.0s | build: 1.0s]
[test:test] package build succeeded (5.00s) [prep: 1.0s | pull: 1.0s | lint: 1.0s | test: 1.0s | build: 1.0s]
`,
},
},
Expand All @@ -78,7 +79,22 @@ func TestConsoleReporter(t *testing.T) {
},
Expect: Expectation{
Output: `[test:test] build started (version unknown)
[test:test] package build succeded (0.00s)
[test:test] package build succeeded (0.00s)
`,
},
},
{
Name: "failed build",
Func: func(t *testing.T, r *ConsoleReporter) {
r.PackageBuildStarted(pkg)
r.PackageBuildFinished(pkg, &PackageBuildReport{
Error: errors.New("failed"),
})
},
Expect: Expectation{
Output: `[test:test] build started (version unknown)
[test:test] package build failed while preping
[test:test] Reason: failed
`,
},
},
Expand Down
Loading