[Bug]: Windows Death Tests have different behavior for CLI options compared to other platforms
rfenner opened this issue · comments
Describe the issue
Windows only uses the command line options passed to it when the test suite starts for death tests only adding the needed filters to run the death test in the child.
Other platforms death tests allow for additional args to be compiled in or use the g_args global variable which when using a custom test main allows one to add additional args to passed to main and then to any death test run
Steps to reproduce the problem
Add an argument to the arguments passed on the command line before passing them into InitGoogleTest and for other platforms the arg will be show up in the death test. On windows only the origional cli options will show up besides the added filter option.
What version of GoogleTest are you using?
1.14.0 f8d7d77
What operating system and version are you using?
Windows 11
What compiler and version are you using?
MSVC 14.39.33519
What build system are you using?
Bazel 6.3.2
Additional context
The problem comes down to line 797 of gtest-death-test.cc where it uses GetCommandLineA instead of building the args from g_args.
What i was doing was passing a test directory flag into any children run partly as a flag to prevent some of the test_main startup code from running and if they needed to output logs or files during the test they knew were to write them
I fixed locally with
std::vector<std::string> args = GetInjectableArgvs();
std::string command_line;
for (std::string arg : args) {
command_line += arg + " ";
}
command_line += filter_flag + " \"" + internal_flag + "\"";