WithStub runs the supplied function with Exit stubbed. It returns the stub used, so that users can test whether the process would have crashed.
(f func())
| 49 | // WithStub runs the supplied function with Exit stubbed. It returns the stub |
| 50 | // used, so that users can test whether the process would have crashed. |
| 51 | func WithStub(f func()) *StubbedExit { |
| 52 | s := Stub() |
| 53 | defer s.Unstub() |
| 54 | f() |
| 55 | return s |
| 56 | } |
| 57 | |
| 58 | // Unstub restores the previous exit function. |
| 59 | func (se *StubbedExit) Unstub() { |