Commit 2b928806 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 the test runner expects skips to fail.

Reviewed By: yfeldblum

Differential Revision: D15210476

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