Skip to content

Commit

Permalink
Windows: add --incompatible_windows_native_test_wrapper
Browse files Browse the repository at this point in the history
Add the --incompatible_windows_native_test_wrapper
flag (default: false). This flag has no effect on
platforms other than Windows.

When using `bazel test`, Bazel does not execute
tests directly. Instead Bazel runs a "test
wrapper" as a subprocess, which sets up the
environment for the test and runs the test.

By default, Bazel uses a Bash script
(`@bazel_tools//tools/test:test-setup.sh`) as the
test wrapper, on all platforms. The new flag
allows using an alternative test wrapper written
in C++ that does not depend on Bash.

Flag semantics:
- When true: Bazel uses the C++ test wrapper from
  `@bazel_tools//tools/test:tw`. This test wrapper
  does not depend on Bash.
- When false: Bazel uses the Bash script test
  wrapper also used on every other platform, from
  `@bazel_tools//tools/test:test-setup.sh`. This
  script requires Bash.

Incompatible flag: bazelbuild#6622

Related: bazelbuild#5508

RELNOTES[NEW]: Added --incompatible_windows_native_test_wrapper flag: enables using the Bash-less test wrapper on Windows. (No-op on other platforms.)
  • Loading branch information
laszlocsomor committed Mar 6, 2019
1 parent faad4b5 commit bcc3d5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.devtools.common.options.OptionDefinition;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsParser;
import com.google.devtools.common.options.OptionsParsingException;
import com.google.devtools.common.options.TriState;
Expand Down Expand Up @@ -211,7 +212,7 @@ public static class TestOptions extends FragmentOptions {
public Label coverageReportGenerator;

@Option(
name = "experimental_windows_native_test_wrapper",
name = "incompatible_windows_native_test_wrapper",
// Design:
// https://github.com/laszlocsomor/proposals/blob/win-test-runner/designs/2018-07-18-windows-native-test-runner.md
documentationCategory = OptionDocumentationCategory.TESTING,
Expand All @@ -221,6 +222,10 @@ public static class TestOptions extends FragmentOptions {
OptionEffectTag.LOADING_AND_ANALYSIS,
OptionEffectTag.TEST_RUNNER,
},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
},
defaultValue = "false",
help =
"On Windows: if true, uses the C++ test wrapper to run tests, otherwise uses "
Expand Down
4 changes: 2 additions & 2 deletions src/test/py/bazel/test_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _AssertXmlGeneratedByTestIsRetained(self, flag, split_xml=False):

def testTestExecutionWithTestSetupSh(self):
self._CreateMockWorkspace()
flag = '--noexperimental_windows_native_test_wrapper'
flag = '--noincompatible_windows_native_test_wrapper'
self._AssertPassingTest(flag)
self._AssertFailingTest(flag)
self._AssertPrintingTest(flag)
Expand Down Expand Up @@ -596,7 +596,7 @@ def testTestExecutionWithTestSetupSh(self):

def testTestExecutionWithTestWrapperExe(self):
self._CreateMockWorkspace()
flag = '--experimental_windows_native_test_wrapper'
flag = '--incompatible_windows_native_test_wrapper'
self._AssertPassingTest(flag)
self._AssertFailingTest(flag)
self._AssertPrintingTest(flag)
Expand Down

0 comments on commit bcc3d5f

Please sign in to comment.