google / google/googletest

[Bug]: Windows Death Tests have different behavior for CLI options compared to other platforms

Open
#4,515 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### 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 f8d7d77c06936315286eb55f8de22cd23c188571

### 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

Contributor guide

Open the contributing guide

Research direction

Start in gtest-death-test.cc around line 797 and trace how Windows constructs arguments for death-test children. Reproduce the issue with a custom test main that adds an argument before InitGoogleTest, then compare the child arguments with other platforms. Done means a regression test demonstrates that the added argument is available to Windows death tests without losing the existing filter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.