From 848f4c6069674dcf3fb683aafdd779be26224d5d Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Mon, 25 Jul 2022 12:36:31 +0100 Subject: [PATCH 01/14] Add support for env_inherit --- go/private/rules/test.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index d0e11a854d..140eb655f8 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -162,6 +162,7 @@ def _go_test_impl(ctx): env = {} for k, v in ctx.attr.env.items(): env[k] = ctx.expand_location(v, ctx.attr.data) + inherited_environment = ctx.attr.env_inherit # Bazel only looks for coverage data if the test target has an # InstrumentedFilesProvider. If the provider is found and at least one @@ -184,7 +185,7 @@ def _go_test_impl(ctx): dependency_attributes = ["data", "deps", "embed", "embedsrcs"], extensions = ["go"], ), - testing.TestEnvironment(env), + testing.TestEnvironment(env, inherited_environment), ] _go_test_kwargs = { @@ -244,6 +245,10 @@ _go_test_kwargs = { [make variable expansion](https://docs.bazel.build/versions/main/be/make-variables.html). """, ), + "env_inherit": attr.string_list( + doc = """Environment variables to inherit from the external environment. + """, + ), "importpath": attr.string( doc = """The import path of this test. Tests can't actually be imported, but this may be used by [go_path] and other tools to report the location of source From e53f2b29afaf963c69f662642891722745dc8093 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Thu, 28 Jul 2022 11:46:37 +0100 Subject: [PATCH 02/14] Keep compat with < 5.2 --- go/private/rules/test.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 140eb655f8..df81823065 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -185,7 +185,7 @@ def _go_test_impl(ctx): dependency_attributes = ["data", "deps", "embed", "embedsrcs"], extensions = ["go"], ), - testing.TestEnvironment(env, inherited_environment), + testing.TestEnvironment(env, inherited_environment) if inherited_environment else testing.TestEnvironment(env), ] _go_test_kwargs = { From e13e7f1d146a2dd8961874580617bf8e5d9b0502 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Thu, 28 Jul 2022 12:03:51 +0100 Subject: [PATCH 03/14] Add skeleton test This will most likely fail CI - not sure how to pass through an env var --- tests/core/go_test/BUILD.bazel | 6 ++++++ tests/core/go_test/env_inherit_test.go | 27 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/core/go_test/env_inherit_test.go diff --git a/tests/core/go_test/BUILD.bazel b/tests/core/go_test/BUILD.bazel index 829ca8d591..2cec7133c7 100644 --- a/tests/core/go_test/BUILD.bazel +++ b/tests/core/go_test/BUILD.bazel @@ -243,3 +243,9 @@ go_test( "@io_bazel_rules_go//go/tools/bazel", ], ) + +go_test( + name = "env_inherit_test", + env_inherit = ["INHERITEDVAR"], + srcs = ["env_inherit_test.go"], +) \ No newline at end of file diff --git a/tests/core/go_test/env_inherit_test.go b/tests/core/go_test/env_inherit_test.go new file mode 100644 index 0000000000..2de41f0ba8 --- /dev/null +++ b/tests/core/go_test/env_inherit_test.go @@ -0,0 +1,27 @@ +// Copyright 2021 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package env_inherit_test + +import ( + "os" + "testing" +) + +func TestEnv(t *testing.T) { + v := os.Getenv("INHERITEDVAR") + if v != "b" { + t.Fatalf("INHERITEDVAR was not equal to b") + } +} From 51da04ce66033b00f78c0850bb85b5903e050970 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Thu, 28 Jul 2022 13:42:47 +0100 Subject: [PATCH 04/14] Add integration test --- tests/core/go_test/BUILD.bazel | 5 ++-- tests/core/go_test/env_inherit_test.go | 36 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/core/go_test/BUILD.bazel b/tests/core/go_test/BUILD.bazel index 2cec7133c7..ac36f93103 100644 --- a/tests/core/go_test/BUILD.bazel +++ b/tests/core/go_test/BUILD.bazel @@ -244,8 +244,7 @@ go_test( ], ) -go_test( +go_bazel_test( name = "env_inherit_test", - env_inherit = ["INHERITEDVAR"], srcs = ["env_inherit_test.go"], -) \ No newline at end of file +) diff --git a/tests/core/go_test/env_inherit_test.go b/tests/core/go_test/env_inherit_test.go index 2de41f0ba8..b425abe2de 100644 --- a/tests/core/go_test/env_inherit_test.go +++ b/tests/core/go_test/env_inherit_test.go @@ -14,14 +14,48 @@ package env_inherit_test +import ( + "os" + "testing" + + "github.com/bazelbuild/rules_go/go/tools/bazel_testing" +) + +func TestMain(m *testing.M) { + bazel_testing.TestMain(m, bazel_testing.Args{ + Main: ` +-- src/BUILD.bazel -- +load("@io_bazel_rules_go//go:def.bzl", "go_test") +go_test( + name = "main", + srcs = ["env_inherit.go"], + env_inherit = ["INHERITEDVAR"], +) +-- src/env_inherit.go -- +package env_inherit_test + import ( "os" "testing" ) -func TestEnv(t *testing.T) { +func TestInherit(t *testing.T) { v := os.Getenv("INHERITEDVAR") if v != "b" { t.Fatalf("INHERITEDVAR was not equal to b") } } +`, + + SetUp: func() error { + os.Setenv("INHERITEDVAR", "b") + return nil + }, + }) +} + +func TestInheritedEnvVar(t *testing.T) { + if err := bazel_testing.RunBazel("test", "//src:main"); err != nil { + t.Fatal(err) + } +} From c27f00a3e9351997da85dbf45237c745e591308a Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Thu, 28 Jul 2022 14:20:02 +0100 Subject: [PATCH 05/14] Update docs --- docs/go/core/rules.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/go/core/rules.md b/docs/go/core/rules.md index e0a70e6629..10f4a9b6dc 100644 --- a/docs/go/core/rules.md +++ b/docs/go/core/rules.md @@ -331,8 +331,8 @@ This declares a set of source files and related dependencies that can be embedde
 go_test(name, cdeps, cgo, clinkopts, copts, cppopts, cxxopts, data, deps, embed, embedsrcs, env,
-        gc_goopts, gc_linkopts, goarch, goos, gotags, importpath, linkmode, msan, pure, race, rundir,
-        srcs, static, x_defs)
+        env_inherit, gc_goopts, gc_linkopts, goarch, goos, gotags, importpath, linkmode, msan, pure,
+        race, rundir, srcs, static, x_defs)
 
This builds a set of tests that can be run with `bazel test`.

@@ -383,6 +383,7 @@ This builds a set of tests that can be run with `bazel test`.

| embed | List of Go libraries whose sources should be compiled together with this package's sources. Labels listed here must name go_library, go_proto_library, or other compatible targets with the [GoLibrary] and [GoSource] providers. Embedded libraries must have the same importpath as the embedding library. At most one embedded library may have cgo = True, and the embedding library may not also have cgo = True. See [Embedding] for more information. | List of labels | optional | [] | | embedsrcs | The list of files that may be embedded into the compiled package using //go:embed directives. All files must be in the same logical directory or a subdirectory as source files. All source files containing //go:embed directives must be in the same logical directory. It's okay to mix static and generated source files and static and generated embeddable files. | List of labels | optional | [] | | env | Environment variables to set for the test execution. The values (but not keys) are subject to [location expansion](https://docs.bazel.build/versions/main/skylark/macros.html) but not full [make variable expansion](https://docs.bazel.build/versions/main/be/make-variables.html). | Dictionary: String -> String | optional | {} | +| env_inherit | Environment variables to inherit from the external environment. | List of strings | optional | [] | | gc_goopts | List of flags to add to the Go compilation command when using the gc compiler. Subject to ["Make variable"] substitution and [Bourne shell tokenization]. | List of strings | optional | [] | | gc_linkopts | List of flags to add to the Go link command when using the gc compiler. Subject to ["Make variable"] substitution and [Bourne shell tokenization]. | List of strings | optional | [] | | goarch | Forces a binary to be cross-compiled for a specific architecture. It's usually better to control this on the command line with --platforms.

This disables cgo by default, since a cross-compiling C/C++ toolchain is rarely available. To force cgo, set pure = off.

See [Cross compilation] for more information. | String | optional | "auto" | From b23ce001eda232cdfdcac60af1324629504bd917 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Mon, 22 Aug 2022 14:12:00 +0100 Subject: [PATCH 06/14] Explicitly check Bazel version --- go/private/rules/test.bzl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index df81823065..71794d262b 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -52,6 +52,7 @@ load( "@bazel_skylib//lib:structs.bzl", "structs", ) +load("//go/private/skylib/lib:versions.bzl", "versions") def _go_test_impl(ctx): """go_test_impl implements go testing. @@ -162,7 +163,14 @@ def _go_test_impl(ctx): env = {} for k, v in ctx.attr.env.items(): env[k] = ctx.expand_location(v, ctx.attr.data) - inherited_environment = ctx.attr.env_inherit + + test_environment = testing.TestEnvironment(env) + if ctx.attr.env_inherit: + # inherited_environment is only available in Bazel 5.2.0+ + # https://github.com/bazelbuild/rules_go/pull/3256 + if not getattr(native, "bazel_version", None) or not versions.check("5.2.0", bazel_version = native.bazel_version): + fail("env_inherit is only available in Bazel 5.2.0 or higher") + test_environment = testing.TestEnvironment(env, ctx.attr.env_inherit) # Bazel only looks for coverage data if the test target has an # InstrumentedFilesProvider. If the provider is found and at least one @@ -185,7 +193,7 @@ def _go_test_impl(ctx): dependency_attributes = ["data", "deps", "embed", "embedsrcs"], extensions = ["go"], ), - testing.TestEnvironment(env, inherited_environment) if inherited_environment else testing.TestEnvironment(env), + test_environment, ] _go_test_kwargs = { From c0509ab1a38c5c1b04e2aabb17be7d1d4cb6a20e Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Mon, 22 Aug 2022 14:17:49 +0100 Subject: [PATCH 07/14] Fix lib import --- go/private/rules/test.bzl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 71794d262b..51e532dbd3 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -52,7 +52,10 @@ load( "@bazel_skylib//lib:structs.bzl", "structs", ) -load("//go/private/skylib/lib:versions.bzl", "versions") +load( + "@bazel_skylib//lib:versions.bzl", + "versions", +) def _go_test_impl(ctx): """go_test_impl implements go testing. From 2f42387ebaf5717de1006ffe71991f613992adea Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Mon, 22 Aug 2022 14:26:40 +0100 Subject: [PATCH 08/14] Import and visibility --- go/private/rules/test.bzl | 2 +- go/private/skylib/lib/BUILD.bazel | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 51e532dbd3..681c9d622f 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -53,7 +53,7 @@ load( "structs", ) load( - "@bazel_skylib//lib:versions.bzl", + "//go/private/skylib/lib:versions.bzl", "versions", ) diff --git a/go/private/skylib/lib/BUILD.bazel b/go/private/skylib/lib/BUILD.bazel index c7cd85c778..f07bb3cdb3 100644 --- a/go/private/skylib/lib/BUILD.bazel +++ b/go/private/skylib/lib/BUILD.bazel @@ -16,5 +16,8 @@ filegroup( bzl_library( name = "versions", srcs = ["versions.bzl"], - visibility = ["//go:__subpackages__"], + visibility = [ + "//go:__subpackages__", + "//go/private/rules:test", + ], ) From 5a41f62a77b24a4b98118de6c0a47e9e0ab0302e Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Mon, 22 Aug 2022 14:29:16 +0100 Subject: [PATCH 09/14] revert changes --- go/private/skylib/lib/BUILD.bazel | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/go/private/skylib/lib/BUILD.bazel b/go/private/skylib/lib/BUILD.bazel index f07bb3cdb3..c7cd85c778 100644 --- a/go/private/skylib/lib/BUILD.bazel +++ b/go/private/skylib/lib/BUILD.bazel @@ -16,8 +16,5 @@ filegroup( bzl_library( name = "versions", srcs = ["versions.bzl"], - visibility = [ - "//go:__subpackages__", - "//go/private/rules:test", - ], + visibility = ["//go:__subpackages__"], ) From 4f5c07b9a41932af769645e921eefa542099d829 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Mon, 22 Aug 2022 14:33:58 +0100 Subject: [PATCH 10/14] Fix dep --- go/private/rules/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/go/private/rules/BUILD.bazel b/go/private/rules/BUILD.bazel index 2de381d597..0c1b847bf0 100644 --- a/go/private/rules/BUILD.bazel +++ b/go/private/rules/BUILD.bazel @@ -132,6 +132,7 @@ bzl_library( "//go/private:providers", "//go/private/rules:binary", "//go/private/rules:transition", + "//go/private/skylib/lib:versions", "@bazel_skylib//lib:structs", ], ) From 3bf2657ed77f907f4a40e52c74803e1e65c67e56 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Wed, 31 Aug 2022 12:00:25 +0100 Subject: [PATCH 11/14] Create bazel_version repo rule and check version --- go/private/repositories.bzl | 14 ++++++++++++++ go/private/rules/test.bzl | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/go/private/repositories.bzl b/go/private/repositories.bzl index 4dc669cee3..0b901cf3fb 100644 --- a/go/private/repositories.bzl +++ b/go/private/repositories.bzl @@ -20,6 +20,18 @@ load("//go/private:nogo.bzl", "DEFAULT_NOGO", "go_register_nogo") load("//proto:gogo.bzl", "gogo_special_proto") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +# native.bazel_version is only available in WORKSPACE macros +# https://github.com/bazelbuild/bazel/issues/8305 +# Needed for guarding env_inherit support https://github.com/bazelbuild/rules_go/pull/3256 which requires 5.2.0+ +def _bazel_version_repository_impl(repository_ctx): + repository_ctx.file("bazel_version.bzl", "bazel_version = \"{}\"".format(native.bazel_version)) + repository_ctx.file("BUILD", "") + +_bazel_version_repository = repository_rule( + implementation = _bazel_version_repository_impl, + local = True, +) + def go_rules_dependencies(force = False): """Declares workspaces the Go rules depend on. Workspaces that use rules_go should call this. @@ -38,6 +50,8 @@ def go_rules_dependencies(force = False): if getattr(native, "bazel_version", None): versions.check(MINIMUM_BAZEL_VERSION, bazel_version = native.bazel_version) + _bazel_version_repository(name = "rules_go_bazel_version") + if force: wrapper = _always else: diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 681c9d622f..76716ed7a5 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -52,6 +52,7 @@ load( "@bazel_skylib//lib:structs.bzl", "structs", ) +load("@rules_go_bazel_version//:bazel_version.bzl", "bazel_version") load( "//go/private/skylib/lib:versions.bzl", "versions", @@ -171,8 +172,7 @@ def _go_test_impl(ctx): if ctx.attr.env_inherit: # inherited_environment is only available in Bazel 5.2.0+ # https://github.com/bazelbuild/rules_go/pull/3256 - if not getattr(native, "bazel_version", None) or not versions.check("5.2.0", bazel_version = native.bazel_version): - fail("env_inherit is only available in Bazel 5.2.0 or higher") + versions.check("5.2.0", bazel_version = bazel_version) test_environment = testing.TestEnvironment(env, ctx.attr.env_inherit) # Bazel only looks for coverage data if the test target has an From bd5628a9d4b23d31ccde7ec07b20cefc2761e129 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Wed, 31 Aug 2022 12:16:22 +0100 Subject: [PATCH 12/14] fix deps --- go/private/rules/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/go/private/rules/BUILD.bazel b/go/private/rules/BUILD.bazel index 0c1b847bf0..13127b67ac 100644 --- a/go/private/rules/BUILD.bazel +++ b/go/private/rules/BUILD.bazel @@ -134,6 +134,7 @@ bzl_library( "//go/private/rules:transition", "//go/private/skylib/lib:versions", "@bazel_skylib//lib:structs", + "@rules_go_bazel_version//:bazel_version.bzl", ], ) From 5d4f3d935f37181845dbfcd7b47e8375988dadf6 Mon Sep 17 00:00:00 2001 From: Talha Pathan Date: Wed, 31 Aug 2022 12:19:57 +0100 Subject: [PATCH 13/14] export file --- go/private/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/private/repositories.bzl b/go/private/repositories.bzl index 0b901cf3fb..99170742c4 100644 --- a/go/private/repositories.bzl +++ b/go/private/repositories.bzl @@ -25,7 +25,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Needed for guarding env_inherit support https://github.com/bazelbuild/rules_go/pull/3256 which requires 5.2.0+ def _bazel_version_repository_impl(repository_ctx): repository_ctx.file("bazel_version.bzl", "bazel_version = \"{}\"".format(native.bazel_version)) - repository_ctx.file("BUILD", "") + repository_ctx.file("BUILD", "exports_files([\"bazel_version.bzl\"])") _bazel_version_repository = repository_rule( implementation = _bazel_version_repository_impl, From 93bb4f7d4579aa2bb652b9bb1b0e6f1fccd267fb Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Sun, 22 Jan 2023 23:11:54 +0100 Subject: [PATCH 14/14] Unconditionally set inherited_environment Requires increasing the minimum Bazel version to 5.2.0. --- .bazelci/presubmit.yml | 2 +- README.rst | 2 +- go/private/common.bzl | 2 +- go/private/repositories.bzl | 14 -------------- go/private/rules/BUILD.bazel | 2 -- go/private/rules/test.bzl | 12 +----------- 6 files changed, 4 insertions(+), 30 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c89129d696..87aa7ff9e1 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -2,7 +2,7 @@ tasks: ubuntu1804_bazel400: platform: ubuntu1804 - bazel: 5.1.0 # test minimum supported version of bazel + bazel: 5.2.0 # test minimum supported version of bazel shell_commands: - tests/core/cgo/generate_imported_dylib.sh build_targets: diff --git a/README.rst b/README.rst index 954cc2d9ed..f32d2c67c8 100644 --- a/README.rst +++ b/README.rst @@ -193,7 +193,7 @@ The Go rules are tested and supported on the following host platforms: Users have reported success on several other platforms, but the rules are only tested on those listed above. -Note: Since version v0.35.0, rules_go requires Bazel ≥ 5.1.0 to work. +Note: Since version v0.38.0, rules_go requires Bazel ≥ 5.2.0 to work. The ``master`` branch is only guaranteed to work with the latest version of Bazel. diff --git a/go/private/common.bzl b/go/private/common.bzl index 7a1c4135ee..d0efaaf951 100644 --- a/go/private/common.bzl +++ b/go/private/common.bzl @@ -169,7 +169,7 @@ def get_versioned_shared_lib_extension(path): # something like 1.2.3, or so.1.2, or dylib.1.2, or foo.1.2 return "" -MINIMUM_BAZEL_VERSION = "5.1.0" +MINIMUM_BAZEL_VERSION = "5.2.0" def as_list(v): """Returns a list, tuple, or depset as a list.""" diff --git a/go/private/repositories.bzl b/go/private/repositories.bzl index 99170742c4..4dc669cee3 100644 --- a/go/private/repositories.bzl +++ b/go/private/repositories.bzl @@ -20,18 +20,6 @@ load("//go/private:nogo.bzl", "DEFAULT_NOGO", "go_register_nogo") load("//proto:gogo.bzl", "gogo_special_proto") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# native.bazel_version is only available in WORKSPACE macros -# https://github.com/bazelbuild/bazel/issues/8305 -# Needed for guarding env_inherit support https://github.com/bazelbuild/rules_go/pull/3256 which requires 5.2.0+ -def _bazel_version_repository_impl(repository_ctx): - repository_ctx.file("bazel_version.bzl", "bazel_version = \"{}\"".format(native.bazel_version)) - repository_ctx.file("BUILD", "exports_files([\"bazel_version.bzl\"])") - -_bazel_version_repository = repository_rule( - implementation = _bazel_version_repository_impl, - local = True, -) - def go_rules_dependencies(force = False): """Declares workspaces the Go rules depend on. Workspaces that use rules_go should call this. @@ -50,8 +38,6 @@ def go_rules_dependencies(force = False): if getattr(native, "bazel_version", None): versions.check(MINIMUM_BAZEL_VERSION, bazel_version = native.bazel_version) - _bazel_version_repository(name = "rules_go_bazel_version") - if force: wrapper = _always else: diff --git a/go/private/rules/BUILD.bazel b/go/private/rules/BUILD.bazel index 13127b67ac..2de381d597 100644 --- a/go/private/rules/BUILD.bazel +++ b/go/private/rules/BUILD.bazel @@ -132,9 +132,7 @@ bzl_library( "//go/private:providers", "//go/private/rules:binary", "//go/private/rules:transition", - "//go/private/skylib/lib:versions", "@bazel_skylib//lib:structs", - "@rules_go_bazel_version//:bazel_version.bzl", ], ) diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl index 76716ed7a5..d30704d006 100644 --- a/go/private/rules/test.bzl +++ b/go/private/rules/test.bzl @@ -52,11 +52,6 @@ load( "@bazel_skylib//lib:structs.bzl", "structs", ) -load("@rules_go_bazel_version//:bazel_version.bzl", "bazel_version") -load( - "//go/private/skylib/lib:versions.bzl", - "versions", -) def _go_test_impl(ctx): """go_test_impl implements go testing. @@ -168,12 +163,7 @@ def _go_test_impl(ctx): for k, v in ctx.attr.env.items(): env[k] = ctx.expand_location(v, ctx.attr.data) - test_environment = testing.TestEnvironment(env) - if ctx.attr.env_inherit: - # inherited_environment is only available in Bazel 5.2.0+ - # https://github.com/bazelbuild/rules_go/pull/3256 - versions.check("5.2.0", bazel_version = bazel_version) - test_environment = testing.TestEnvironment(env, ctx.attr.env_inherit) + test_environment = testing.TestEnvironment(env, ctx.attr.env_inherit) # Bazel only looks for coverage data if the test target has an # InstrumentedFilesProvider. If the provider is found and at least one