diff --git a/dmarcdb/main_test.go b/dmarcdb/main_test.go new file mode 100644 index 0000000..88bd2ec --- /dev/null +++ b/dmarcdb/main_test.go @@ -0,0 +1,17 @@ +package dmarcdb + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/http/main_test.go b/http/main_test.go new file mode 100644 index 0000000..3dedd91 --- /dev/null +++ b/http/main_test.go @@ -0,0 +1,17 @@ +package http + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/imapserver/main_test.go b/imapserver/main_test.go new file mode 100644 index 0000000..06caee4 --- /dev/null +++ b/imapserver/main_test.go @@ -0,0 +1,17 @@ +package imapserver + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..88ea9c4 --- /dev/null +++ b/main_test.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/metrics/panic.go b/metrics/panic.go index aaf0fe1..dea4553 100644 --- a/metrics/panic.go +++ b/metrics/panic.go @@ -1,6 +1,8 @@ package metrics import ( + "sync/atomic" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) @@ -72,6 +74,9 @@ func init() { } } +var Panics atomic.Int64 + func PanicInc(name Panic) { + Panics.Add(1) metricPanic.WithLabelValues(string(name)).Inc() } diff --git a/mtasts/main_test.go b/mtasts/main_test.go new file mode 100644 index 0000000..1346a4f --- /dev/null +++ b/mtasts/main_test.go @@ -0,0 +1,17 @@ +package mtasts + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/mtastsdb/main_test.go b/mtastsdb/main_test.go new file mode 100644 index 0000000..c9a2f2c --- /dev/null +++ b/mtastsdb/main_test.go @@ -0,0 +1,17 @@ +package mtastsdb + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/queue/main_test.go b/queue/main_test.go new file mode 100644 index 0000000..c1ae6b3 --- /dev/null +++ b/queue/main_test.go @@ -0,0 +1,17 @@ +package queue + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/smtpserver/main_test.go b/smtpserver/main_test.go new file mode 100644 index 0000000..f265f2e --- /dev/null +++ b/smtpserver/main_test.go @@ -0,0 +1,17 @@ +package smtpserver + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/store/main_test.go b/store/main_test.go new file mode 100644 index 0000000..8754e10 --- /dev/null +++ b/store/main_test.go @@ -0,0 +1,17 @@ +package store + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/tlsrptsend/main_test.go b/tlsrptsend/main_test.go new file mode 100644 index 0000000..30eb08d --- /dev/null +++ b/tlsrptsend/main_test.go @@ -0,0 +1,17 @@ +package tlsrptsend + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/webaccount/main_test.go b/webaccount/main_test.go new file mode 100644 index 0000000..ec4ee9c --- /dev/null +++ b/webaccount/main_test.go @@ -0,0 +1,17 @@ +package webaccount + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/webadmin/main_test.go b/webadmin/main_test.go new file mode 100644 index 0000000..f77cd80 --- /dev/null +++ b/webadmin/main_test.go @@ -0,0 +1,17 @@ +package webadmin + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/webapisrv/main_test.go b/webapisrv/main_test.go new file mode 100644 index 0000000..9512682 --- /dev/null +++ b/webapisrv/main_test.go @@ -0,0 +1,17 @@ +package webapisrv + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +} diff --git a/webmail/main_test.go b/webmail/main_test.go new file mode 100644 index 0000000..bec3cb9 --- /dev/null +++ b/webmail/main_test.go @@ -0,0 +1,17 @@ +package webmail + +import ( + "fmt" + "os" + "testing" + + "github.com/mjl-/mox/metrics" +) + +func TestMain(m *testing.M) { + m.Run() + if metrics.Panics.Load() > 0 { + fmt.Println("unhandled panics encountered") + os.Exit(2) + } +}