internal/crashmonitor: fix TestViaStderr/trap
I believe there’s a mistake in commit 06ef541f:
What used to be:
if got != want {
t.Errorf("got counter name <<%s>>, want <<%s>>", got, want)
}
became the following in TestViaStderr/panic:
if !wantRE.MatchString(got) {
t.Errorf("got counter name <<%s>>, want match for <<%s>>", got, wantRE)
}
…but the condition was negated in TestViaStderr/trap:
if wantRE.MatchString(got) {
t.Errorf("got counter name <<%s>>, want match for <<%s>>", got, wantRE)
}
This only went unnoticed because the crash stack line numbers are incorrect.
I noticed this when importing the x/telemetry package into google3,
where the package names are different and need an update.
Change-Id: I6327d174d09d0073c1e18e46618e0fd35e6b4e0c
Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/713780
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/crashmonitor/monitor_test.go b/internal/crashmonitor/monitor_test.go
index cef3343..a2033a9 100644
--- a/internal/crashmonitor/monitor_test.go
+++ b/internal/crashmonitor/monitor_test.go
@@ -135,11 +135,11 @@
runtime.sigpanic:--
golang.org/x/telemetry/internal/crashmonitor_test.grandchildTrap:=96,\+0x.*
golang.org/x/telemetry/internal/crashmonitor_test.childTrap:\+2,\+0x.*
-golang.org/x/telemetry/internal/crashmonitor_test.TestMain:\+10,\+0x.*
+golang.org/x/telemetry/internal/crashmonitor_test.TestMain:\+12,\+0x.*
main.main:--
runtime.main:--
runtime.goexit:--`)
- if wantRE.MatchString(got) {
+ if !wantRE.MatchString(got) {
t.Errorf("got counter name <<%s>>, want match for <<%s>>", got, wantRE)
}
})