Skip to content

Commit b3a4f65

Browse files
Pass env to gentestmain so it will correctly filter (#3785)
This is a fairly simple change and the test is also simple. Without the addition test.bzl, the new cgo_required test fails to compile. It's more of a regression test than anything else.
1 parent d74d9ab commit b3a4f65

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

go/private/rules/test.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def _go_test_impl(ctx):
120120
executable = go.toolchain._builder,
121121
arguments = [arguments],
122122
toolchain = GO_TOOLCHAIN_LABEL,
123+
env = go.env,
123124
)
124125

125126
test_gc_linkopts = gc_linkopts(ctx)

tests/core/cgo/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,9 @@ cc_binary(
472472
srcs = ["use_c_symbol_through_go.c"],
473473
deps = [":use_transitive_symbol"],
474474
)
475+
476+
go_test(
477+
name = "cgo_required",
478+
srcs = ["cgo_required_test.go"],
479+
pure = "on",
480+
)

tests/core/cgo/cgo_required_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build cgo
2+
// +build cgo
3+
4+
package cgo_required
5+
6+
import "testing"
7+
8+
// Without correct filtering, gentestmain will try to link against this test
9+
// that does not exist with pure = True
10+
func TestHelloWorld(t *testing.T) {}

0 commit comments

Comments
 (0)