diff --git a/build/BUILD b/build/BUILD index 20793e1f7b9..465e395594b 100644 --- a/build/BUILD +++ b/build/BUILD @@ -155,7 +155,7 @@ filegroup( srcs = select(for_platforms( for_server = [ "//cmd/kubemark", - "//test/e2e_node:e2e_node.test_binary", + "//test/e2e_node:e2e_node.test", ], for_test = [ "//cmd/gendocs", @@ -164,7 +164,7 @@ filegroup( "//cmd/genswaggertypedocs", "//cmd/genyaml", "//cmd/linkcheck", - "//test/e2e:e2e.test_binary", + "//test/e2e:e2e.test", "//vendor/github.com/onsi/ginkgo/ginkgo", "//cluster/images/conformance/go-runner", ], diff --git a/build/go.bzl b/build/go.bzl index 58ce9c101b0..b7b6bbc798b 100644 --- a/build/go.bzl +++ b/build/go.bzl @@ -14,90 +14,36 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") -# Defines several go_binary rules to work around a Bazel issue which makes -# the pure attribute on go_binary not configurable. -# The name provided will have cgo enabled if targeting Linux, and will -# be a pure go binary otherwise. Additionally, if targeting Windows, the -# output filename will have a .exe suffix. -def go_binary_conditional_pure(name, tags = None, **kwargs): - tags = tags or [] - tags.append("manual") +# Defines a go_binary rule that enables cgo on platform builds targeting Linux, +# and otherwise builds a pure go binary. +def go_binary_conditional_pure(name, tags = [], **kwargs): go_binary( - name = "_%s-cgo" % name, - out = name, - pure = "off", - tags = tags, - **kwargs - ) - - # Define a rule for both Unix and Windows exe suffixes. - [go_binary( - name = "_%s-pure" % out, - out = out, - pure = "on", - tags = tags, - **kwargs - ) for out in [name, name + ".exe"]] - - # The real magic, where we work around the pure attribute not being - # configurable: select the appropriate go_binary rule above based on the - # configured platform. - native.alias( name = name, - actual = select({ - "@io_bazel_rules_go//go/platform:linux": ":_%s-cgo" % name, - "@io_bazel_rules_go//go/platform:windows": ":_%s.exe-pure" % name, - "//conditions:default": ":_%s-pure" % name, + pure = select({ + "@io_bazel_rules_go//go/platform:linux": "off", + "//conditions:default": "on", }), + tags = ["manual"] + tags, + **kwargs ) -# Defines several go_test rules to work around a Bazel issue which makes -# the pure attribute on go_test not configurable. -# This also defines genrules to produce test binaries named ${out} and -# ${out}.exe, and an alias named ${out}_binary which automatically selects -# the correct filename suffix (i.e. with a .exe on Windows). -def go_test_conditional_pure(name, out, tags = None, **kwargs): - tags = tags or [] +# Defines a go_test rule that enables cgo on platform builds targeting Linux, +# and otherwise builds a pure go binary. +def go_test_conditional_pure(name, out, tags = [], **kwargs): tags.append("manual") go_test( - name = "_%s-cgo" % name, - pure = "off", - testonly = False, - tags = tags, - **kwargs - ) - - go_test( - name = "_%s-pure" % name, - pure = "on", + name = out, + pure = select({ + "@io_bazel_rules_go//go/platform:linux": "off", + "//conditions:default": "on", + }), testonly = False, tags = tags, **kwargs ) native.alias( - name = name, - actual = select({ - "@io_bazel_rules_go//go/platform:linux": ":_%s-cgo" % name, - "//conditions:default": ":_%s-pure" % name, - }), - ) - - [native.genrule( - name = "gen_%s" % o, - srcs = [name], - outs = [o], - cmd = "cp $< $@;", - output_to_bindir = True, - executable = True, - tags = tags, - ) for o in [out, out + ".exe"]] - - native.alias( - name = "%s_binary" % out, - actual = select({ - "@io_bazel_rules_go//go/platform:windows": ":gen_%s.exe" % out, - "//conditions:default": ":gen_%s" % out, - }), + name = "name", + actual = out, ) diff --git a/cluster/images/conformance/BUILD b/cluster/images/conformance/BUILD index b25c140f4e4..9bac3144122 100644 --- a/cluster/images/conformance/BUILD +++ b/cluster/images/conformance/BUILD @@ -15,7 +15,7 @@ container_layer( files = [ "//cluster/images/conformance/go-runner", "//cmd/kubectl", - "//test/e2e:e2e.test_binary", + "//test/e2e:e2e.test", "//vendor/github.com/onsi/ginkgo/ginkgo", ], ) diff --git a/test/conformance/BUILD b/test/conformance/BUILD index b8ec7993333..bb9003038c0 100644 --- a/test/conformance/BUILD +++ b/test/conformance/BUILD @@ -45,11 +45,11 @@ genrule( srcs = [ "//test/e2e:all-srcs", "//test/e2e_node:all-srcs", - "//test/e2e:e2e.test_binary", + "//test/e2e:e2e.test", "//vendor/github.com/onsi/ginkgo/ginkgo", ], outs = ["specsummaries.json"], - cmd = "$(location //vendor/github.com/onsi/ginkgo/ginkgo) --dryRun=true --focus=[Conformance] $(location //test/e2e:e2e.test_binary) -- --spec-dump $$(pwd)/$@ > /dev/null", + cmd = "$(location //vendor/github.com/onsi/ginkgo/ginkgo) --dryRun=true --focus=[Conformance] $(location //test/e2e:e2e.test) -- --spec-dump $$(pwd)/$@ > /dev/null", message = "Getting all conformance spec summaries.", )