Skip to content

Commit df15713

Browse files
suertreusCJ-Johnson
authored andcommitted
Googletest export
Add a note documenting that death test macros accept arbitrary gmock matchers against child-process stderr, not just regexes. PiperOrigin-RevId: 372365998
1 parent f381758 commit df15713

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

googletest/include/gtest/gtest-death-test.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ GTEST_API_ bool InDeathTestChild();
9797
//
9898
// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
9999
//
100+
// The final parameter to each of these macros is a matcher applied to any data
101+
// the sub-process wrote to stderr. For compatibility with existing tests, a
102+
// bare string is interpreted as a regular expression matcher.
103+
//
100104
// On the regular expressions used in death tests:
101105
//
102106
// GOOGLETEST_CM0005 DO NOT DELETE
@@ -162,27 +166,27 @@ GTEST_API_ bool InDeathTestChild();
162166
// directory in PATH.
163167
//
164168

165-
// Asserts that a given statement causes the program to exit, with an
166-
// integer exit status that satisfies predicate, and emitting error output
167-
// that matches regex.
168-
# define ASSERT_EXIT(statement, predicate, regex) \
169-
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
169+
// Asserts that a given `statement` causes the program to exit, with an
170+
// integer exit status that satisfies `predicate`, and emitting error output
171+
// that matches `matcher`.
172+
# define ASSERT_EXIT(statement, predicate, matcher) \
173+
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_)
170174

171-
// Like ASSERT_EXIT, but continues on to successive tests in the
175+
// Like `ASSERT_EXIT`, but continues on to successive tests in the
172176
// test suite, if any:
173-
# define EXPECT_EXIT(statement, predicate, regex) \
174-
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
177+
# define EXPECT_EXIT(statement, predicate, matcher) \
178+
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_NONFATAL_FAILURE_)
175179

176-
// Asserts that a given statement causes the program to exit, either by
180+
// Asserts that a given `statement` causes the program to exit, either by
177181
// explicitly exiting with a nonzero exit code or being killed by a
178-
// signal, and emitting error output that matches regex.
179-
# define ASSERT_DEATH(statement, regex) \
180-
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
182+
// signal, and emitting error output that matches `matcher`.
183+
# define ASSERT_DEATH(statement, matcher) \
184+
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
181185

182-
// Like ASSERT_DEATH, but continues on to successive tests in the
186+
// Like `ASSERT_DEATH`, but continues on to successive tests in the
183187
// test suite, if any:
184-
# define EXPECT_DEATH(statement, regex) \
185-
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
188+
# define EXPECT_DEATH(statement, matcher) \
189+
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
186190

187191
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
188192

0 commit comments

Comments
 (0)