From 0571e7329b46083af40adfa096b4eda998ed1d9e Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Tue, 10 Sep 2024 18:59:34 +0000 Subject: [PATCH 1/2] try and add an xdef to mimic what go toolset toes for testing.Testing https://pkg.go.dev/testing\#Testing --- go/private/rules/test.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 5ee3f855c..5986e881d 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -311,6 +311,7 @@ _go_test_kwargs = { doc = """Map of defines to add to the go link command. See [Defines and stamping] for examples of how to use these. """, + "testing.testBinary" = "1", ), "linkmode": attr.string( default = "auto", From 907dc64c4429308e6bff6f13cf2d2642be43df40 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Tue, 10 Sep 2024 20:00:08 +0000 Subject: [PATCH 2/2] maybe this is it --- go/private/rules/test.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 5986e881d..c297def4e 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -150,7 +150,8 @@ def _go_test_impl(ctx): # before user code. See comment above the init function # in bzltestutil/init.go. test_gc_linkopts.extend(["-X", "+initfirst/github.com/bazelbuild/rules_go/go/tools/bzltestutil/chdir.RunDir=" + run_dir]) - + #post golang 1.23 testing.Testing is expected to be set for go tests + test_gc_linkopts.extend(["-X", "testing.Testing=1"]) # Now compile the test binary itself test_library = GoLibrary( name = go.label.name + "~testmain", @@ -311,7 +312,6 @@ _go_test_kwargs = { doc = """Map of defines to add to the go link command. See [Defines and stamping] for examples of how to use these. """, - "testing.testBinary" = "1", ), "linkmode": attr.string( default = "auto",