| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -773,6 +773,35 @@ class GeMatcher | |||
| 773 | 773 | static const char* NegatedDesc() { return "isn't >="; } | |
| 774 | 774 | }; | |
| 775 | 775 | ||
| 776 | + // Same as `EqMatcher<Rhs>`, except that the `rhs` is stored as `StoredRhs` and | ||
| 777 | + // must be implicitly convertible to `Rhs`. | ||
| 778 | + template <typename Rhs, typename StoredRhs> | ||
| 779 | + class ImplicitCastEqMatcher { | ||
| 780 | + public: | ||
| 781 | + explicit ImplicitCastEqMatcher(const StoredRhs& rhs) : stored_rhs_(rhs) {} | ||
| 782 | + | ||
| 783 | + using is_gtest_matcher = void; | ||
| 784 | + | ||
| 785 | + template <typename Lhs> | ||
| 786 | + bool MatchAndExplain(const Lhs& lhs, std::ostream*) const { | ||
| 787 | + return lhs == rhs(); | ||
| 788 | + } | ||
| 789 | + | ||
| 790 | + void DescribeTo(std::ostream* os) const { | ||
| 791 | + *os << "is equal to "; | ||
| 792 | + UniversalPrint(rhs(), os); | ||
| 793 | + } | ||
| 794 | + void DescribeNegationTo(std::ostream* os) const { | ||
| 795 | + *os << "isn't equal to "; | ||
| 796 | + UniversalPrint(rhs(), os); | ||
| 797 | + } | ||
| 798 | + | ||
| 799 | + private: | ||
| 800 | + Rhs rhs() const { return ImplicitCast_<Rhs>(stored_rhs_); } | ||
| 801 | + | ||
| 802 | + StoredRhs stored_rhs_; | ||
| 803 | + }; | ||
| 804 | + | ||
| 776 | 805 | template <typename T, typename = typename std::enable_if< | |
| 777 | 806 | std::is_constructible<std::string, T>::value>::type> | |
| 778 | 807 | using StringLike = T; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,6 +269,13 @@ GTEST_DEFINE_bool_( | |||
| 269 | 269 | "True if and only if the test should fail if no test case (including " | |
| 270 | 270 | "disabled test cases) is linked."); | |
| 271 | 271 | ||
| 272 | + GTEST_DEFINE_bool_( | ||
| 273 | + fail_if_no_test_selected, | ||
| 274 | + testing::internal::BoolFromGTestEnv("fail_if_no_test_selected", false), | ||
| 275 | + "True if and only if the test should fail if no test case is selected to " | ||
| 276 | + "run. A test case is selected to run if it is not disabled and is matched " | ||
| 277 | + "by the filter flag so that it starts executing."); | ||
| 278 | + | ||
| 272 | 279 | GTEST_DEFINE_bool_( | |
| 273 | 280 | also_run_disabled_tests, | |
| 274 | 281 | testing::internal::BoolFromGTestEnv("also_run_disabled_tests", false), | |
@@ -6079,6 +6086,14 @@ bool UnitTestImpl::RunAllTests() { | |||
| 6079 | 6086 | TearDownEnvironment); | |
| 6080 | 6087 | repeater->OnEnvironmentsTearDownEnd(*parent_); | |
| 6081 | 6088 | } | |
| 6089 | + } else if (GTEST_FLAG_GET(fail_if_no_test_selected)) { | ||
| 6090 | + // If there were no tests to run, bail if we were requested to be strict. | ||
| 6091 | + constexpr char kNoTestsSelectedMessage[] = | ||
| 6092 | + "No tests were selected to run. Please make sure at least one test " | ||
| 6093 | + "exists and is not disabled! If the test is sharded, you may have " | ||
| 6094 | + "defined more shards than test cases, which is wasteful."; | ||
| 6095 | + ColoredPrintf(GTestColor::kRed, "%s\n", kNoTestsSelectedMessage); | ||
| 6096 | + return false; | ||
| 6082 | 6097 | } | |
| 6083 | 6098 | ||
| 6084 | 6099 | elapsed_time_ = timer.Elapsed(); | |
@@ -6763,6 +6778,7 @@ static bool ParseGoogleTestFlag(const char* const arg) { | |||
| 6763 | 6778 | GTEST_INTERNAL_PARSE_FLAG(death_test_use_fork); | |
| 6764 | 6779 | GTEST_INTERNAL_PARSE_FLAG(fail_fast); | |
| 6765 | 6780 | GTEST_INTERNAL_PARSE_FLAG(fail_if_no_test_linked); | |
| 6781 | + GTEST_INTERNAL_PARSE_FLAG(fail_if_no_test_selected); | ||
| 6766 | 6782 | GTEST_INTERNAL_PARSE_FLAG(filter); | |
| 6767 | 6783 | GTEST_INTERNAL_PARSE_FLAG(internal_run_death_test); | |
| 6768 | 6784 | GTEST_INTERNAL_PARSE_FLAG(list_tests); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments