Skip to content

Commit 43c784a

Browse files
committed
Set non-zero exit code for build/run errors when using -set-exit-code
1 parent e6ab84c commit 43c784a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

go-junit-report.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func main() {
102102
}
103103
fmt.Fprintf(out, "\n")
104104

105-
if *setExitCode && report.HasFailures() {
105+
if *setExitCode && !report.IsSuccessful() {
106106
os.Exit(1)
107107
}
108108
}

pkg/gtr/gtr.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ type Report struct {
1919
Packages []Package
2020
}
2121

22-
func (r *Report) HasFailures() bool {
22+
func (r *Report) IsSuccessful() bool {
2323
for _, pkg := range r.Packages {
24+
if pkg.BuildError.Name != "" || pkg.RunError.Name != "" {
25+
return false
26+
}
2427
for _, t := range pkg.Tests {
25-
if t.Result == Fail {
26-
return true
28+
if t.Result != Pass && t.Result != Skip {
29+
return false
2730
}
2831
}
2932
}
30-
return false
33+
return true
3134
}
3235

3336
type Package struct {

0 commit comments

Comments
 (0)