| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent aa8bdb6 commit 0925953
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1424,12 +1424,11 @@ class GTEST_API_ Mutex { | |||
| 1424 | 1424 | // "MutexLock l(&mu)". Hence the typedef trick below. | |
| 1425 | 1425 | class GTestMutexLock { | |
| 1426 | 1426 | public: | |
| 1427 | - explicit GTestMutexLock(Mutex* mutex) : mutex_(mutex) { mutex_->lock(); } | ||
| 1428 | - | ||
| 1429 | - ~GTestMutexLock() { mutex_->unlock(); } | ||
| 1427 | + explicit GTestMutexLock(Mutex& mutex) : mutex_(mutex) { mutex_.lock(); } | ||
| 1428 | + ~GTestMutexLock() { mutex_.unlock(); } | ||
| 1430 | 1429 | ||
| 1431 | 1430 | private: | |
| 1432 | - Mutex* const mutex_; | ||
| 1431 | + Mutex& mutex_; | ||
| 1433 | 1432 | ||
| 1434 | 1433 | GTestMutexLock(const GTestMutexLock&) = delete; | |
| 1435 | 1434 | GTestMutexLock& operator=(const GTestMutexLock&) = delete; | |
@@ -1716,12 +1715,11 @@ class Mutex : public MutexBase { | |||
| 1716 | 1715 | // "MutexLock l(&mu)". Hence the typedef trick below. | |
| 1717 | 1716 | class GTestMutexLock { | |
| 1718 | 1717 | public: | |
| 1719 | - explicit GTestMutexLock(MutexBase* mutex) : mutex_(mutex) { mutex_->lock(); } | ||
| 1720 | - | ||
| 1721 | - ~GTestMutexLock() { mutex_->unlock(); } | ||
| 1718 | + explicit GTestMutexLock(MutexBase& mutex) : mutex_(mutex) { mutex_.lock(); } | ||
| 1719 | + ~GTestMutexLock() { mutex_.unlock(); } | ||
| 1722 | 1720 | ||
| 1723 | 1721 | private: | |
| 1724 | - MutexBase* const mutex_; | ||
| 1722 | + MutexBase& mutex_; | ||
| 1725 | 1723 | ||
| 1726 | 1724 | GTestMutexLock(const GTestMutexLock&) = delete; | |
| 1727 | 1725 | GTestMutexLock& operator=(const GTestMutexLock&) = delete; | |
@@ -1881,7 +1879,7 @@ class Mutex { | |||
| 1881 | 1879 | // "MutexLock l(&mu)". Hence the typedef trick below. | |
| 1882 | 1880 | class GTestMutexLock { | |
| 1883 | 1881 | public: | |
| 1884 | - explicit GTestMutexLock(Mutex*) {} // NOLINT | ||
| 1882 | + explicit GTestMutexLock(Mutex&) {} // NOLINT | ||
| 1885 | 1883 | }; | |
| 1886 | 1884 | ||
| 1887 | 1885 | typedef GTestMutexLock MutexLock; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -499,7 +499,7 @@ class ThreadLocalRegistryImpl { | |||
| 499 | 499 | MemoryIsNotDeallocated memory_is_not_deallocated; | |
| 500 | 500 | #endif // _MSC_VER | |
| 501 | 501 | DWORD current_thread = ::GetCurrentThreadId(); | |
| 502 | - MutexLock lock(&mutex_); | ||
| 502 | + MutexLock lock(mutex_); | ||
| 503 | 503 | ThreadIdToThreadLocals* const thread_to_thread_locals = | |
| 504 | 504 | GetThreadLocalsMapLocked(); | |
| 505 | 505 | ThreadIdToThreadLocals::iterator thread_local_pos = | |
@@ -532,7 +532,7 @@ class ThreadLocalRegistryImpl { | |||
| 532 | 532 | // Clean up the ThreadLocalValues data structure while holding the lock, but | |
| 533 | 533 | // defer the destruction of the ThreadLocalValueHolderBases. | |
| 534 | 534 | { | |
| 535 | - MutexLock lock(&mutex_); | ||
| 535 | + MutexLock lock(mutex_); | ||
| 536 | 536 | ThreadIdToThreadLocals* const thread_to_thread_locals = | |
| 537 | 537 | GetThreadLocalsMapLocked(); | |
| 538 | 538 | for (ThreadIdToThreadLocals::iterator it = | |
@@ -559,7 +559,7 @@ class ThreadLocalRegistryImpl { | |||
| 559 | 559 | // Clean up the ThreadIdToThreadLocals data structure while holding the | |
| 560 | 560 | // lock, but defer the destruction of the ThreadLocalValueHolderBases. | |
| 561 | 561 | { | |
| 562 | - MutexLock lock(&mutex_); | ||
| 562 | + MutexLock lock(mutex_); | ||
| 563 | 563 | ThreadIdToThreadLocals* const thread_to_thread_locals = | |
| 564 | 564 | GetThreadLocalsMapLocked(); | |
| 565 | 565 | ThreadIdToThreadLocals::iterator thread_local_pos = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1086,14 +1086,14 @@ void DefaultPerThreadTestPartResultReporter::ReportTestPartResult( | |||
| 1086 | 1086 | // Returns the global test part result reporter. | |
| 1087 | 1087 | TestPartResultReporterInterface* | |
| 1088 | 1088 | UnitTestImpl::GetGlobalTestPartResultReporter() { | |
| 1089 | - internal::MutexLock lock(&global_test_part_result_reporter_mutex_); | ||
| 1089 | + internal::MutexLock lock(global_test_part_result_reporter_mutex_); | ||
| 1090 | 1090 | return global_test_part_result_reporter_; | |
| 1091 | 1091 | } | |
| 1092 | 1092 | ||
| 1093 | 1093 | // Sets the global test part result reporter. | |
| 1094 | 1094 | void UnitTestImpl::SetGlobalTestPartResultReporter( | |
| 1095 | 1095 | TestPartResultReporterInterface* reporter) { | |
| 1096 | - internal::MutexLock lock(&global_test_part_result_reporter_mutex_); | ||
| 1096 | + internal::MutexLock lock(global_test_part_result_reporter_mutex_); | ||
| 1097 | 1097 | global_test_part_result_reporter_ = reporter; | |
| 1098 | 1098 | } | |
| 1099 | 1099 | ||
@@ -2347,7 +2347,7 @@ void TestResult::RecordProperty(const std::string& xml_element, | |||
| 2347 | 2347 | if (!ValidateTestProperty(xml_element, test_property)) { | |
| 2348 | 2348 | return; | |
| 2349 | 2349 | } | |
| 2350 | - internal::MutexLock lock(&test_properties_mutex_); | ||
| 2350 | + internal::MutexLock lock(test_properties_mutex_); | ||
| 2351 | 2351 | const std::vector<TestProperty>::iterator property_with_matching_key = | |
| 2352 | 2352 | std::find_if(test_properties_.begin(), test_properties_.end(), | |
| 2353 | 2353 | internal::TestPropertyKeyIs(test_property.key())); | |
@@ -5088,7 +5088,7 @@ std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) | |||
| 5088 | 5088 | ||
| 5089 | 5089 | void* caller_frame = nullptr; | |
| 5090 | 5090 | { | |
| 5091 | - MutexLock lock(&mutex_); | ||
| 5091 | + MutexLock lock(mutex_); | ||
| 5092 | 5092 | caller_frame = caller_frame_; | |
| 5093 | 5093 | } | |
| 5094 | 5094 | ||
@@ -5127,7 +5127,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { | |||
| 5127 | 5127 | caller_frame = nullptr; | |
| 5128 | 5128 | } | |
| 5129 | 5129 | ||
| 5130 | - MutexLock lock(&mutex_); | ||
| 5130 | + MutexLock lock(mutex_); | ||
| 5131 | 5131 | caller_frame_ = caller_frame; | |
| 5132 | 5132 | #endif // GTEST_HAS_ABSL | |
| 5133 | 5133 | } | |
@@ -5390,13 +5390,13 @@ void UnitTest::UponLeavingGTest() { | |||
| 5390 | 5390 | ||
| 5391 | 5391 | // Sets the TestSuite object for the test that's currently running. | |
| 5392 | 5392 | void UnitTest::set_current_test_suite(TestSuite* a_current_test_suite) { | |
| 5393 | - internal::MutexLock lock(&mutex_); | ||
| 5393 | + internal::MutexLock lock(mutex_); | ||
| 5394 | 5394 | impl_->set_current_test_suite(a_current_test_suite); | |
| 5395 | 5395 | } | |
| 5396 | 5396 | ||
| 5397 | 5397 | // Sets the TestInfo object for the test that's currently running. | |
| 5398 | 5398 | void UnitTest::set_current_test_info(TestInfo* a_current_test_info) { | |
| 5399 | - internal::MutexLock lock(&mutex_); | ||
| 5399 | + internal::MutexLock lock(mutex_); | ||
| 5400 | 5400 | impl_->set_current_test_info(a_current_test_info); | |
| 5401 | 5401 | } | |
| 5402 | 5402 | ||
@@ -5435,7 +5435,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, | |||
| 5435 | 5435 | Message msg; | |
| 5436 | 5436 | msg << message; | |
| 5437 | 5437 | ||
| 5438 | - internal::MutexLock lock(&mutex_); | ||
| 5438 | + internal::MutexLock lock(mutex_); | ||
| 5439 | 5439 | if (!impl_->gtest_trace_stack().empty()) { | |
| 5440 | 5440 | msg << "\n" << GTEST_NAME_ << " trace:"; | |
| 5441 | 5441 | ||
@@ -5618,15 +5618,15 @@ const char* UnitTest::original_working_dir() const { | |||
| 5618 | 5618 | // or NULL if no test is running. | |
| 5619 | 5619 | const TestSuite* UnitTest::current_test_suite() const | |
| 5620 | 5620 | GTEST_LOCK_EXCLUDED_(mutex_) { | |
| 5621 | - internal::MutexLock lock(&mutex_); | ||
| 5621 | + internal::MutexLock lock(mutex_); | ||
| 5622 | 5622 | return impl_->current_test_suite(); | |
| 5623 | 5623 | } | |
| 5624 | 5624 | ||
| 5625 | 5625 | // Legacy API is still available but deprecated | |
| 5626 | 5626 | #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ | |
| 5627 | 5627 | const TestCase* UnitTest::current_test_case() const | |
| 5628 | 5628 | GTEST_LOCK_EXCLUDED_(mutex_) { | |
| 5629 | - internal::MutexLock lock(&mutex_); | ||
| 5629 | + internal::MutexLock lock(mutex_); | ||
| 5630 | 5630 | return impl_->current_test_suite(); | |
| 5631 | 5631 | } | |
| 5632 | 5632 | #endif | |
@@ -5635,7 +5635,7 @@ const TestCase* UnitTest::current_test_case() const | |||
| 5635 | 5635 | // or NULL if no test is running. | |
| 5636 | 5636 | const TestInfo* UnitTest::current_test_info() const | |
| 5637 | 5637 | GTEST_LOCK_EXCLUDED_(mutex_) { | |
| 5638 | - internal::MutexLock lock(&mutex_); | ||
| 5638 | + internal::MutexLock lock(mutex_); | ||
| 5639 | 5639 | return impl_->current_test_info(); | |
| 5640 | 5640 | } | |
| 5641 | 5641 | ||
@@ -5659,13 +5659,13 @@ UnitTest::~UnitTest() { delete impl_; } | |||
| 5659 | 5659 | // Google Test trace stack. | |
| 5660 | 5660 | void UnitTest::PushGTestTrace(const internal::TraceInfo& trace) | |
| 5661 | 5661 | GTEST_LOCK_EXCLUDED_(mutex_) { | |
| 5662 | - internal::MutexLock lock(&mutex_); | ||
| 5662 | + internal::MutexLock lock(mutex_); | ||
| 5663 | 5663 | impl_->gtest_trace_stack().push_back(trace); | |
| 5664 | 5664 | } | |
| 5665 | 5665 | ||
| 5666 | 5666 | // Pops a trace from the per-thread Google Test trace stack. | |
| 5667 | 5667 | void UnitTest::PopGTestTrace() GTEST_LOCK_EXCLUDED_(mutex_) { | |
| 5668 | - internal::MutexLock lock(&mutex_); | ||
| 5668 | + internal::MutexLock lock(mutex_); | ||
| 5669 | 5669 | impl_->gtest_trace_stack().pop_back(); | |
| 5670 | 5670 | } | |
| 5671 | 5671 | ||
@@ -6088,15 +6088,17 @@ bool UnitTestImpl::RunAllTests() { | |||
| 6088 | 6088 | repeater->OnEnvironmentsTearDownEnd(*parent_); | |
| 6089 | 6089 | } | |
| 6090 | 6090 | } else if (GTEST_FLAG_GET(fail_if_no_test_selected)) { | |
| 6091 | - // If there were no tests to run, bail if we were requested to be strict. | ||
| 6091 | + // If there were no tests to run, bail if we were requested to be | ||
| 6092 | + // strict. | ||
| 6092 | 6093 | constexpr char kNoTestsSelectedMessage[] = | |
| 6093 | - "No tests were selected to run. Please make sure at least one test " | ||
| 6094 | - "exists and is not disabled! If the test is sharded, you may have " | ||
| 6095 | - "defined more shards than test cases, which is wasteful. If you also " | ||
| 6096 | - "defined --gtest_filter, that filter is taken into account, so " | ||
| 6097 | - "shards with no matching test cases will hit this error. Either " | ||
| 6098 | - "disable sharding, set --gtest_fail_if_no_test_selected=false, or " | ||
| 6099 | - "remove the filter to resolve this error."; | ||
| 6094 | + "No tests ran. Check that tests exist and are not disabled or " | ||
| 6095 | + "filtered out.\n\n" | ||
| 6096 | + "For sharded runs, this error indicates an empty shard. This can " | ||
| 6097 | + "happen if you have more shards than tests, or if --gtest_filter " | ||
| 6098 | + "leaves a shard with no tests.\n\n" | ||
| 6099 | + "To permit empty shards (e.g., when debugging with a filter), " | ||
| 6100 | + "specify \n" | ||
| 6101 | + "--gtest_fail_if_no_test_selected=false."; | ||
| 6100 | 6102 | ColoredPrintf(GTestColor::kRed, "%s\n", kNoTestsSelectedMessage); | |
| 6101 | 6103 | return false; | |
| 6102 | 6104 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments