aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorshiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2009-01-10 01:16:33 +0000
committershiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2009-01-10 01:16:33 +0000
commitfe186c382905dcf57014985ccea8e067275e9f5f (patch)
treeb857251b28c8d30b4338f9107abb8a1541f355d2 /src
parent53e0dc4041f660b6517b15b08b496e164be614f1 (diff)
downloadgoogletest-fe186c382905dcf57014985ccea8e067275e9f5f.tar.gz
googletest-fe186c382905dcf57014985ccea8e067275e9f5f.tar.bz2
googletest-fe186c382905dcf57014985ccea8e067275e9f5f.zip
Implements --gtest_also_run_disabled_tests. By Eric Roman.
Diffstat (limited to 'src')
-rw-r--r--src/gtest-internal-inl.h7
-rw-r--r--src/gtest.cc16
2 files changed, 18 insertions, 5 deletions
diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h
index 353c40a6..5808a50c 100644
--- a/src/gtest-internal-inl.h
+++ b/src/gtest-internal-inl.h
@@ -63,6 +63,7 @@ namespace testing {
// We don't want the users to modify these flags in the code, but want
// Google Test's own unit tests to be able to access them. Therefore we
// declare them here as opposed to in gtest.h.
+GTEST_DECLARE_bool_(also_run_disabled_tests);
GTEST_DECLARE_bool_(break_on_failure);
GTEST_DECLARE_bool_(catch_exceptions);
GTEST_DECLARE_string_(color);
@@ -72,8 +73,8 @@ GTEST_DECLARE_bool_(list_tests);
GTEST_DECLARE_string_(output);
GTEST_DECLARE_bool_(print_time);
GTEST_DECLARE_int32_(repeat);
-GTEST_DECLARE_int32_(stack_trace_depth);
GTEST_DECLARE_bool_(show_internal_stack_frames);
+GTEST_DECLARE_int32_(stack_trace_depth);
namespace internal {
@@ -82,6 +83,7 @@ namespace internal {
extern const TypeId kTestTypeIdInGoogleTest;
// Names of the flags (needed for parsing Google Test flags).
+const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
const char kBreakOnFailureFlag[] = "break_on_failure";
const char kCatchExceptionsFlag[] = "catch_exceptions";
const char kColorFlag[] = "color";
@@ -97,6 +99,7 @@ class GTestFlagSaver {
public:
// The c'tor.
GTestFlagSaver() {
+ also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);
break_on_failure_ = GTEST_FLAG(break_on_failure);
catch_exceptions_ = GTEST_FLAG(catch_exceptions);
color_ = GTEST_FLAG(color);
@@ -112,6 +115,7 @@ class GTestFlagSaver {
// The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS.
~GTestFlagSaver() {
+ GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;
GTEST_FLAG(break_on_failure) = break_on_failure_;
GTEST_FLAG(catch_exceptions) = catch_exceptions_;
GTEST_FLAG(color) = color_;
@@ -126,6 +130,7 @@ class GTestFlagSaver {
}
private:
// Fields for saving the original values of flags.
+ bool also_run_disabled_tests_;
bool break_on_failure_;
bool catch_exceptions_;
String color_;
diff --git a/src/gtest.cc b/src/gtest.cc
index ae20d874..0e3115ba 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -154,6 +154,11 @@ const char kStackTraceMarker[] = "\nStack trace:\n";
} // namespace internal
GTEST_DEFINE_bool_(
+ also_run_disabled_tests,
+ internal::BoolFromGTestEnv("also_run_disabled_tests", false),
+ "Run disabled tests too, in addition to the tests normally being run.");
+
+GTEST_DEFINE_bool_(
break_on_failure,
internal::BoolFromGTestEnv("break_on_failure", false),
"True iff a failed assertion should be a debugger break-point.");
@@ -1610,7 +1615,7 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
right = towlower(*rhs++);
} while (left && left == right);
return left == right;
-#endif // OS selector
+#endif // OS selector
}
// Constructs a String by copying a given number of chars from a
@@ -2736,7 +2741,7 @@ void PrettyUnitTestResultPrinter::OnUnitTestEnd(
}
int num_disabled = impl->disabled_test_count();
- if (num_disabled) {
+ if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (!num_failures) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
@@ -3602,7 +3607,8 @@ int UnitTestImpl::FilterTests() {
kDisableTestFilter);
test_info->impl()->set_is_disabled(is_disabled);
- const bool should_run = !is_disabled &&
+ const bool should_run =
+ (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
internal::UnitTestOptions::FilterMatchesTest(test_case_name,
test_name);
test_info->impl()->set_should_run(should_run);
@@ -3860,7 +3866,9 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
using internal::ParseStringFlag;
// Do we see a Google Test flag?
- if (ParseBoolFlag(arg, kBreakOnFailureFlag,
+ if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
+ &GTEST_FLAG(also_run_disabled_tests)) ||
+ ParseBoolFlag(arg, kBreakOnFailureFlag,
&GTEST_FLAG(break_on_failure)) ||
ParseBoolFlag(arg, kCatchExceptionsFlag,
&GTEST_FLAG(catch_exceptions)) ||