Skip to content

Commit 1556c31

Browse files
committed
runtime: use at least "system" traceback level for runtime tests
While the default behavior of eliding runtime frames from tracebacks usually makes sense, this is not the case when you're trying to test the runtime itself. Fix this by forcing the traceback level to at least "system" in the runtime tests. This will specifically help with debugging issue #13645, which has proven remarkably resistant to reproduction outside of the build dashboard itself. Change-Id: I2a8356ba6c3c5badba8bb3330fc527357ec0d296 Reviewed-on: https://go-review.googlesource.com/18648 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
1 parent c5a2f36 commit 1556c31

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/runtime/export_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,11 @@ var TestingAssertE2I2GC = &testingAssertE2I2GC
163163
var TestingAssertE2T2GC = &testingAssertE2T2GC
164164

165165
var ForceGCPeriod = &forcegcperiod
166+
167+
// SetTracebackEnv is like runtime/debug.SetTraceback, but it raises
168+
// the "environment" traceback level, so later calls to
169+
// debug.SetTraceback (e.g., from testing timeouts) can't lower it.
170+
func SetTracebackEnv(level string) {
171+
setTraceback(level)
172+
traceback_env = traceback_cache
173+
}

src/runtime/runtime_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import (
1212
"unsafe"
1313
)
1414

15+
func init() {
16+
// We're testing the runtime, so make tracebacks show things
17+
// in the runtime. This only raises the level, so it won't
18+
// override GOTRACEBACK=crash from the user.
19+
SetTracebackEnv("system")
20+
}
21+
1522
var errf error
1623

1724
func errfn() error {

0 commit comments

Comments
 (0)