diff --git a/docs/kotlin.md b/docs/kotlin.md
index aaa1b9ba7..33a78e326 100755
--- a/docs/kotlin.md
+++ b/docs/kotlin.md
@@ -204,9 +204,9 @@ kt_jvm_library(name, name, associates, data, deps, env, javac_opts, jvm_flags, kotlinc_opts, main_class,
- module_name, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, srcs,
- test_class)
+kt_jvm_test(name, associates, data, deps, env, env_inherit, javac_opts, jvm_flags, kotlinc_opts,
+ main_class, module_name, plugins, resource_jars, resource_strip_prefix, resources,
+ runtime_deps, srcs, test_class)
Setup a simple kotlin_test.
@@ -226,6 +226,7 @@ kt_jvm_test(name, data | The list of files needed by this rule at runtime. See general comments about data
at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] |
|deps | A list of dependencies of this rule.See general comments about deps
at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] |
|env | Specifies additional environment variables to set when the target is executed by bazel test. | Dictionary: String -> String | optional | {} |
+|env_inherit | Environment variables to inherit from the external environment. | List of strings | optional | [] |
|javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None |
|jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | [] |
|kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None |
diff --git a/kotlin/internal/jvm/impl.bzl b/kotlin/internal/jvm/impl.bzl
index 4c6569829..7404a779b 100644
--- a/kotlin/internal/jvm/impl.bzl
+++ b/kotlin/internal/jvm/impl.bzl
@@ -306,7 +306,7 @@ def kt_jvm_junit_test_impl(ctx):
direct = ctx.files._java_runtime,
),
# adds common test variables, including TEST_WORKSPACE.
- testing.TestEnvironment(environment = ctx.attr.env),
+ testing.TestEnvironment(environment = ctx.attr.env, inherited_environment = ctx.attr.env_inherit),
)
_KtCompilerPluginClasspathInfo = provider(
diff --git a/kotlin/internal/jvm/jvm.bzl b/kotlin/internal/jvm/jvm.bzl
index bef495e43..386cb2aa3 100644
--- a/kotlin/internal/jvm/jvm.bzl
+++ b/kotlin/internal/jvm/jvm.bzl
@@ -353,6 +353,9 @@ Setup a simple kotlin_test.
doc = "Specifies additional environment variables to set when the target is executed by bazel test.",
default = {},
),
+ "env_inherit": attr.string_list(
+ doc = "Environment variables to inherit from the external environment.",
+ ),
"_lcov_merger": attr.label(
default = Label("@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main"),
),