Treat `rc` first called as exit code
Because default OsExiter is os.Exit.
@@ -12,9 +12,11 @@ func TestHandleExitCoder_nil(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
exitCode = rc
called = true
}
+ }
defer func() { OsExiter = fakeOsExiter }()
@@ -29,9 +31,11 @@ func TestHandleExitCoder_ExitCoder(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
exitCode = rc
called = true
}
+ }
defer func() { OsExiter = fakeOsExiter }()
@@ -46,9 +50,11 @@ func TestHandleExitCoder_MultiErrorWithExitCoder(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
exitCode = rc
called = true
}
+ }
defer func() { OsExiter = fakeOsExiter }()
@@ -65,9 +71,11 @@ func TestHandleExitCoder_ErrorWithMessage(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
exitCode = rc
called = true
}
+ }
ErrWriter = &bytes.Buffer{}
defer func() {
@@ -88,9 +96,11 @@ func TestHandleExitCoder_ErrorWithoutMessage(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
exitCode = rc
called = true
}
+ }
ErrWriter = &bytes.Buffer{}
defer func() {
@@ -123,8 +133,10 @@ func TestHandleExitCoder_ErrorWithFormat(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
called = true
}
+ }
ErrWriter = &bytes.Buffer{}
defer func() {
@@ -143,8 +155,10 @@ func TestHandleExitCoder_MultiErrorWithFormat(t *testing.T) {
called := false
OsExiter = func(rc int) {
+ if !called {
called = true
}
+ }
ErrWriter = &bytes.Buffer{}
defer func() { OsExiter = fakeOsExiter }()
