Skip to content

Commit

Permalink
test_wrapper_test: fix for incompatible flag
Browse files Browse the repository at this point in the history
--incompatible_windows_style_arg_escaping will no
longer break this test.

see bazelbuild#7454
  • Loading branch information
laszlocsomor committed Apr 5, 2019
1 parent b9fd6f2 commit dd6148b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
6 changes: 6 additions & 0 deletions src/test/py/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ py_test(
}),
)

py_test(
name = "printarg",
srcs = ["printarg.py"],
args = ["foo", "a b", "", "bar"],
)

py_test(
name = "first_time_use_test",
srcs = ["first_time_use_test.py"],
Expand Down
49 changes: 24 additions & 25 deletions src/test/py/bazel/test_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def _CreateMockWorkspace(self):
' name = "unexported_test.bat",',
' srcs = ["unexported.bat"],',
')',
'sh_test(',
' name = "testargs_test.bat",',
' srcs = ["testargs.bat"],',
' args = ["foo", "a b", "", "bar"],',
'py_test(',
' name = "testargs",',
' srcs = ["testargs.py"],',
r' args = ["foo", "a b", "", r"c\ d", "\'\'", "bar"],',
')',
'py_test(',
' name = "undecl_test",',
Expand Down Expand Up @@ -135,18 +135,12 @@ def _CreateMockWorkspace(self):
],
executable=True)
self.ScratchFile(
'foo/testargs.bat',
'foo/testargs.py',
[
'@echo arg=(%~nx0)', # basename of $0
'@echo arg=(%1)',
'@echo arg=(%2)',
'@echo arg=(%3)',
'@echo arg=(%4)',
'@echo arg=(%5)',
'@echo arg=(%6)',
'@echo arg=(%7)',
'@echo arg=(%8)',
'@echo arg=(%9)',
'from __future__ import print_function',
'import sys',
'for a in sys.argv[1:]:',
' print("arg=(%s)" % a)',
],
executable=True)

Expand Down Expand Up @@ -384,8 +378,12 @@ def _AssertTestArgs(self, flag, expected):
bazel_bin = bazel_bin[0]

exit_code, stdout, stderr = self.RunBazel([
# --[no]incompatible_windows_style_arg_escaping affects what arguments
# the test receives. Run with --incompatible_windows_style_arg_escaping
# to test for future (as of 2019-04-05) behavior.
'--incompatible_windows_style_arg_escaping',
'test',
'//foo:testargs_test.bat',
'//foo:testargs',
'-t-',
'--test_output=all',
'--test_arg=baz',
Expand Down Expand Up @@ -568,10 +566,11 @@ def testTestExecutionWithTestSetupSh(self):
self._AssertTestArgs(
flag,
[
'(testargs_test.bat)',
'(foo)',
'(a)',
'(b)',
'(c d)',
'()',
'(bar)',
# Note: debugging shows that test-setup.sh receives more-or-less
# good arguments (let's ignore issues #6276 and #6277 for now), but
Expand All @@ -582,10 +581,9 @@ def testTestExecutionWithTestSetupSh(self):
# The test is here merely to guard against unwanted future change of
# behavior.
'(baz)',
'("\\"x)',
'(y\\"")',
'("\\\\\\")',
'(qux")'
'("x y")',
'("")',
'(qux)',
])
self._AssertUndeclaredOutputs(flag)
self._AssertUndeclaredOutputsAnnotations(flag)
Expand All @@ -606,7 +604,6 @@ def testTestExecutionWithTestWrapperExe(self):
self._AssertTestArgs(
flag,
[
'(testargs_test.bat)',
'(foo)',
# TODO(laszlocsomor): assert that "a b" is passed as one argument,
# not two, after https://github.com/bazelbuild/bazel/issues/6277
Expand All @@ -616,12 +613,14 @@ def testTestExecutionWithTestWrapperExe(self):
# TODO(laszlocsomor): assert that the empty string argument is
# passed, after https://github.com/bazelbuild/bazel/issues/6276
# is fixed.
'(c)',
'(d)',
'()',
'(bar)',
'(baz)',
'("x y")',
'("")',
'(x y)',
'()',
'(qux)',
'()'
])
self._AssertUndeclaredOutputs(flag)
self._AssertUndeclaredOutputsAnnotations(flag)
Expand Down

0 comments on commit dd6148b

Please sign in to comment.