googletest
googletest copied to clipboard
gtest_premature_exit_test isn't being run correctly
Describe the bug
gtest_premature_exit_test expects to find an environment variable "TEST_PREMATURE_EXIT_FILE" telling it where to find a file needed to run the test properly. If this environment variable isn't set, the test doesn't verify anything.
Running the test under make test
doesn't set the environment variable.
I don't have Bazel set up, but grepping the tree doesn't find anything that
suggests it sets up the environment variable either.
Steps to reproduce the bug
In PrematureExitDeathTest.FileExistsDuringExecutionOfDeathTest,
put assert(false);
or EXPECT_TRUE(false);
before the
EXPECT_DEATH_IF_SUPPORTED call. It won't fire.
In PrematureExitTest.PrematureExitFileExistsDuringTestExecution,
put assert(false);
or EXPECT_TRUE(false);
before the
EXPECT__TRUE call; it won't fire.
The problem might be clearer if the early return
in those test functions
used GTEST_SKIP
instead; then the test wouldn't look like it worked.
If I manually set the environment variable, the test does work correctly.
Does the bug persist in the most recent commit?
yes
What operating system and version are you using?
Ubuntu 18.04
What compiler and version are you using?
gcc 7.5.0
What build system are you using?
cmake version 3.17.3
Additional context
Found by the Rotten Green Tests project (see issue #3811)