-
-
Notifications
You must be signed in to change notification settings - Fork 720
Open
Description
We want to opt-in our monorepo into goroutine leak detection and we plan on using uber-go/leak. One option for us is to change template to something like
+. {{if not .TestMain}}
+ "go.uber.org/goleak"
+. {{end}}
{{if not .TestMain}}
- res := m.Run()
+ goleak.VerifyTestMain(m)
{{else}}
{{.TestMain}}(m)
{{/* See golang.org/issue/34129 and golang.org/cl/219639 */}}
res := int(reflect.ValueOf(m).Elem().FieldByName("exitCode").Int())
- {{end}}
os.Exit(res)
But then we need to introduce goleak as a dependency to rules_go which may or may not be acceptable. One way we can think of making this optional is to allow us to pass in a custom template that we will have and will give us flexibility. A potential parameter could be
"test_main_template": attr.label(
default = "//go/tools/builders/templates:test_main",
allow_file = True,
),
Note, we still need a way to add this dependency (deps = ["@org_uber_go_goleak//:go_default_library"]). One option is to make _testmain_additional_deps public.
sywhang, oncilla and ian-h-chamberlain
Metadata
Metadata
Assignees
Labels
No labels