Commit 43e2ad6e authored by Chad Austin's avatar Chad Austin Committed by Facebook Github Bot

detect at runtime whether SKIP should fail

Summary:
Detect at runtime whether testpilot is the test runner to decide how
to communicate skip status.

Reviewed By: simpkins

Differential Revision: D15073229

fbshipit-source-id: 417a1f4e42d0655e25cc62b0abb016c157d1adea
parent c0b4901a
......@@ -45,17 +45,20 @@
// the test due to runtime issues or behavior that do not necessarily indicate
// a problem with the code.
//
// googletest does not have a built-in mechanism to report tests as skipped a
// run time. We either report the test as successful or failure based on the
// FOLLY_SKIP_AS_FAILURE configuration setting. The default is to report the
// test as successful. Enabling FOLLY_SKIP_AS_FAILURE can be useful with a
// test harness that can identify the "Test skipped by client" in the failure
// message and convert this into a skipped test result.
#if FOLLY_SKIP_AS_FAILURE
#define SKIP() GTEST_FATAL_FAILURE_("Test skipped by client")
#else
#define SKIP() return GTEST_SUCCESS_("Test skipped by client")
#endif
// googletest does not have a built-in mechanism to report tests as
// skipped a run time. We either report the test as successful or
// failure based on whether the TEST_PILOT environment variable is
// set. The default is to report the test as successful. Enabling
// FOLLY_SKIP_AS_FAILURE can be useful with a test harness that can
// identify the "Test skipped by client" in the failure message and
// convert this into a skipped test result.
#define SKIP() \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
return GTEST_MESSAGE_( \
"Test skipped by client", \
::folly::test::detail::skipIsFailure() \
? ::testing::TestPartResult::kFatalFailure \
: ::testing::TestPartResult::kSuccess)
// Encapsulate conditional-skip, since it's nontrivial to get right.
#define SKIP_IF(expr) \
......@@ -143,6 +146,11 @@ AreWithinSecs(T1 val1, T2 val2, std::chrono::seconds acceptableDeltaSecs) {
namespace detail {
inline bool skipIsFailure() {
const char* p = getenv("FOLLY_SKIP_AS_FAILURE");
return p && *p;
}
/**
* Helper class for implementing test macros
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment