Skip to content

Commit ad246c5

Browse files
committed
fix #529: exit with code 7 when error was logged
1 parent c92a7a3 commit ad246c5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pkg/commands/run.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,23 @@ func (e *Executor) setupExitCode(ctx context.Context) {
415415
if ctx.Err() != nil {
416416
e.exitCode = exitcodes.Timeout
417417
e.log.Errorf("Deadline exceeded: try increase it by passing --deadline option")
418+
return
418419
}
419420

420-
if e.exitCode == exitcodes.Success &&
421-
(os.Getenv("GL_TEST_RUN") == "1" || os.Getenv("FAIL_ON_WARNINGS") == "1") &&
422-
len(e.reportData.Warnings) != 0 {
421+
if e.exitCode != exitcodes.Success {
422+
return
423+
}
423424

425+
needFailOnWarnings := (os.Getenv("GL_TEST_RUN") == "1" || os.Getenv("FAIL_ON_WARNINGS") == "1")
426+
if needFailOnWarnings && len(e.reportData.Warnings) != 0 {
424427
e.exitCode = exitcodes.WarningInTest
428+
return
429+
}
430+
431+
if e.reportData.Error != "" {
432+
// it's a case e.g. when typecheck linter couldn't parse and error and just logged it
433+
e.exitCode = exitcodes.ErrorWasLogged
434+
return
425435
}
426436
}
427437

pkg/exitcodes/exitcodes.go

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const (
88
Timeout = 4
99
NoGoFiles = 5
1010
NoConfigFileDetected = 6
11+
ErrorWasLogged = 7
1112
)
1213

1314
type ExitError struct {

0 commit comments

Comments
 (0)