Skip to content

Commit f514228

Browse files
authored
Merge pull request #4 from moul/dev/moul/exit-code
feat: smart exit codes
2 parents 2c3b7ea + b9fb7ba commit f514228

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func runTest(ctx context.Context, args []string) error {
115115
}
116116
defer os.RemoveAll(tmpdir)
117117

118+
atLeastOneFailure := false
118119
// list tests
119120
for _, pkg := range pkgs {
120121
tests, err := listDirTests(pkg.Dir)
@@ -130,7 +131,7 @@ func runTest(ctx context.Context, args []string) error {
130131
return err
131132
}
132133

133-
everythingIsOK := true
134+
isPackageOK := true
134135
for _, test := range tests {
135136
// FIXME: check if matches run regex
136137
args := []string{
@@ -149,15 +150,19 @@ func runTest(ctx context.Context, args []string) error {
149150
if opts.verbose {
150151
fmt.Println(string(out))
151152
}
152-
everythingIsOK = false
153+
isPackageOK = false
154+
atLeastOneFailure = true
153155
}
154156
}
155-
if everythingIsOK {
157+
if isPackageOK {
156158
fmt.Printf("ok\t%s\t%s\n", pkg.ImportPath, time.Since(pkgStart))
157159
}
158160
}
159161

160162
fmt.Printf("total: %s\n", time.Since(start))
163+
if atLeastOneFailure {
164+
os.Exit(1)
165+
}
161166
return nil
162167
}
163168

0 commit comments

Comments
 (0)