Add signal tests for main (#685)

Added tests to validate the process receiving signals:
- SIGTERM and SIGINT exit.
- SIGUSR2 swaps logs

Removed the empty Fprintln in main. Turns out stderr isn't thread safe
to write from multiple locations. The logger, which is otherwise the
only stderr writing goroutine creates a sync writer. But the stderr in
main remains unsafe. This is something to fix later?

There are also races happening with the swap log test, but only when the
test runs in parallel. I'm not sure what's happening there... added a
flag to make this test synchronous for now.

Tests that depend on signals don't run on windows. That's a big todo.
I moved SIGUSR2 behind build tags, so the binary will at least compile.
This commit is contained in:
Victor Vrantchan
2020-07-11 14:51:31 -04:00
committed by GitHub
parent dc6fa6fb53
commit ba9d2a9601
5 changed files with 156 additions and 4 deletions

View File

@@ -4,5 +4,5 @@ package log
import "os"
// TODO(@groob) implement
// TODO(issues/686) implement signals for windows
var defaultSwapSignal = os.Signal(nil)