|
|
@@ -13,8 +13,19 @@ import (
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
)
|
|
|
|
|
|
+// ResourceCheck takes a snapshot of the current goroutines and registers a
|
|
|
+// cleanup on tb to verify that after the rest, all goroutines created by the
|
|
|
+// test go away. (well, at least that the count matches. Maybe in the future it
|
|
|
+// can look at specific routines).
|
|
|
+//
|
|
|
+// It panics if called from a parallel test.
|
|
|
func ResourceCheck(tb testing.TB) {
|
|
|
tb.Helper()
|
|
|
+
|
|
|
+ // Set an environment variable (anything at all) just for the
|
|
|
+ // side effect of tb.Setenv panicking if we're in a parallel test.
|
|
|
+ tb.Setenv("TS_CHECKING_RESOURCES", "1")
|
|
|
+
|
|
|
startN, startStacks := goroutines()
|
|
|
tb.Cleanup(func() {
|
|
|
if tb.Failed() {
|