Add support for env_inherit (#942)
diff --git a/docs/kotlin.md b/docs/kotlin.md index c2faaca..1c96221 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md
@@ -175,8 +175,8 @@ <pre> load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test") -kt_jvm_test(<a href="#kt_jvm_test-name">name</a>, <a href="#kt_jvm_test-deps">deps</a>, <a href="#kt_jvm_test-srcs">srcs</a>, <a href="#kt_jvm_test-data">data</a>, <a href="#kt_jvm_test-resources">resources</a>, <a href="#kt_jvm_test-associates">associates</a>, <a href="#kt_jvm_test-env">env</a>, <a href="#kt_jvm_test-java_stub_template">java_stub_template</a>, <a href="#kt_jvm_test-javac_opts">javac_opts</a>, - <a href="#kt_jvm_test-jvm_flags">jvm_flags</a>, <a href="#kt_jvm_test-kotlinc_opts">kotlinc_opts</a>, <a href="#kt_jvm_test-main_class">main_class</a>, <a href="#kt_jvm_test-module_name">module_name</a>, <a href="#kt_jvm_test-plugins">plugins</a>, <a href="#kt_jvm_test-resource_jars">resource_jars</a>, +kt_jvm_test(<a href="#kt_jvm_test-name">name</a>, <a href="#kt_jvm_test-deps">deps</a>, <a href="#kt_jvm_test-srcs">srcs</a>, <a href="#kt_jvm_test-data">data</a>, <a href="#kt_jvm_test-resources">resources</a>, <a href="#kt_jvm_test-associates">associates</a>, <a href="#kt_jvm_test-env">env</a>, <a href="#kt_jvm_test-env_inherit">env_inherit</a>, <a href="#kt_jvm_test-java_stub_template">java_stub_template</a>, + <a href="#kt_jvm_test-javac_opts">javac_opts</a>, <a href="#kt_jvm_test-jvm_flags">jvm_flags</a>, <a href="#kt_jvm_test-kotlinc_opts">kotlinc_opts</a>, <a href="#kt_jvm_test-main_class">main_class</a>, <a href="#kt_jvm_test-module_name">module_name</a>, <a href="#kt_jvm_test-plugins">plugins</a>, <a href="#kt_jvm_test-resource_jars">resource_jars</a>, <a href="#kt_jvm_test-resource_strip_prefix">resource_strip_prefix</a>, <a href="#kt_jvm_test-runtime_deps">runtime_deps</a>, <a href="#kt_jvm_test-test_class">test_class</a>) </pre> @@ -198,6 +198,7 @@ | <a id="kt_jvm_test-resources"></a>resources | A list of files that should be include in a Java jar. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | | <a id="kt_jvm_test-associates"></a>associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | | <a id="kt_jvm_test-env"></a>env | Specifies additional environment variables to set when the target is executed by bazel test. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | +| <a id="kt_jvm_test-env_inherit"></a>env_inherit | Environment variables to inherit from the external environment. | List of strings | optional | `[]` | | <a id="kt_jvm_test-java_stub_template"></a>java_stub_template | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `"@rules_kotlin//third_party:java_stub_template.txt"` | | <a id="kt_jvm_test-javac_opts"></a>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. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | | <a id="kt_jvm_test-jvm_flags"></a>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 | `[]` |
diff --git a/kotlin/internal/jvm/impl.bzl b/kotlin/internal/jvm/impl.bzl index 2136946..1c31861 100644 --- a/kotlin/internal/jvm/impl.bzl +++ b/kotlin/internal/jvm/impl.bzl
@@ -315,7 +315,7 @@ 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 7ffeb7f..2dff7f2 100644 --- a/kotlin/internal/jvm/jvm.bzl +++ b/kotlin/internal/jvm/jvm.bzl
@@ -371,6 +371,9 @@ 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"), ),