Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: native test wrapper incorrectly escapes arguments [blocking #6622] #7956

Closed
laszlocsomor opened this issue Apr 5, 2019 · 0 comments
Assignees
Labels
area-Windows Windows-specific issues and feature requests P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@laszlocsomor
Copy link
Contributor

Description of the problem / feature request:

The Windows-native test wrapper should escape arguments when running the test.
To escape them, it should use

std::wstring WindowsEscapeArg2(const std::wstring& arg);

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

BUILD:

py_test(
    name = "testargs",
    srcs = ["testargs.py"],
    args = ["foo", "a b", "", r"c\ d", "\'\'", "bar"],
)

testargs.py:

from __future__ import print_function
import sys
for a in sys.argv[1:]:
    print("arg=(%s)" % a)

Build Bazel from HEAD, e.g. afeb8d0.

Then use this binary:

C:\src\tmp>c:\src\bazel\bazel-bin\src\bazel.exe --incompatible_windows_style_arg_escaping test --incompatible_windows_native_test_wrapper //:testargs -t- --test_output=all
(...)
==================== Test output for //:testargs:
arg=(foo)
arg=(a)
arg=(b)
arg=(c)
arg=(d)
arg=()
arg=(bar)
================================================================================

The desired output is:

arg=(foo)
arg=(a)
arg=(b)
arg=(c d)
arg=()
arg=(bar)

i.e. c d is one argument.

What operating system are you running Bazel on?

windows 10

What's the output of bazel info release?

I built bazel from HEAD (afeb8d0).

Any other information, logs, or outputs that you want to share?

This is blocking #6622

@laszlocsomor laszlocsomor self-assigned this Apr 5, 2019
@laszlocsomor laszlocsomor added P2 We'll consider working on this in future. (Assignee optional) area-Windows Windows-specific issues and feature requests type: bug labels Apr 5, 2019
laszlocsomor added a commit to laszlocsomor/bazel that referenced this issue Apr 5, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

Fixes bazelbuild#7956
Unblocks bazelbuild#6622
dkelmer pushed a commit that referenced this issue Apr 11, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
dkelmer pushed a commit that referenced this issue Apr 16, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
dkelmer pushed a commit that referenced this issue Apr 25, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
dkelmer pushed a commit that referenced this issue Apr 25, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
dkelmer pushed a commit that referenced this issue Apr 25, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
dkelmer pushed a commit that referenced this issue Apr 26, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
dkelmer pushed a commit that referenced this issue Apr 29, 2019
The native test wrapper now correctly escapes the
arguments for the subprocess, using
bazel::launcher::WindowsEscapeArg2 from the native
launcher.

The test_wrapper_test now uses a mock C++ binary
instead of a .bat file to verify the test
arguments. Doing so trades the weird command line
flag parsing logic of cmd.exe (inherent in using a
.bat file) for the saner C++ flag parsing one.

Fixes #7956
Unblocks #6622

Closes #7957.

PiperOrigin-RevId: 242446422
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

2 participants