summaryrefslogtreecommitdiffstats
path: root/googletest/src
Commit message (Collapse)AuthorAgeFilesLines
* gtest: Reword fail_if_no_test_selected_message for sharding and filtering.David Pizzuto8 days1-1/+5
| | | | | | | | Users have shown some confusion about the interaction between this flag, sharding, and --gtest_filter, so let's provide some more information. PiperOrigin-RevId: 776734799 Change-Id: Icdcf6aa056988095f15588758994604d326c0567
* Merge pull request #4694 from chromy:mainCopybara-Service11 days1-0/+1
|\ | | | | | | | | PiperOrigin-RevId: 775667059 Change-Id: I07edd44ae368ae640d7b985800ffee8cc663c07f
| * Default to color output for ghosttyrefs/pull/4694/headHector Dearman2025-01-101-0/+1
| |
* | googletest: Add a flag to fail if no tests were selected to run.David Pizzuto2025-06-091-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two cases that prompt this behavior: - All test cases in the binary are disabled. - There are more shards defined than test cases, so some shards are empty. The result in each case is the same: the test runner needs to spin up additional processes that do nothing, which is wasteful, especially when tests need expensive resources. PiperOrigin-RevId: 769176856 Change-Id: Ifa399a0b7b68e4add5a94ca148b32b2938a8666d
* | Fix unified diff headers.Abseil Team2025-05-301-9/+9
| | | | | | | | | | | | | | | | The length part (only) of each range is optional when equal to one. See http://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html PiperOrigin-RevId: 765326445 Change-Id: I4aec68e82f889e3b4f01861d3b6a16a8b2785ce6
* | Use the provided length in ConditionalPrintAsTextAbseil Team2025-05-301-1/+1
| | | | | | | | | | | | | | | | | | While ConditionalPrintAsText gets a char pointer and the string length, it used to only pass the pointer to operator<<. That does not work for strings that are not zero terminated, because operator<< has to resort to strlen, which happily overflows the string buffer. This CL wraps the char pointer and the length in a string_view and passes that to operator<< to fix that issue. PiperOrigin-RevId: 765137769 Change-Id: Ie97067ce9d5b23175a512945fee943a8b95a94ff
* | Print std::basic_string_view<Char> as a string literalDaniel Cheng2025-05-221-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a followup to a previous change switching std::u8string, std::u16string, and std::u32string to print as string literals instead of an array of characters. Also update the PrintCharsAsStringTo<Char>() helper to handle cases where the pointer to the string data is null; unlike std::basic_string<Char>, std::basic_string_view<Char>'s data() is allowed to return nullptr. The new PrintTo overloads complicate the PrintTo(internal::StringView) overload, which needs to be disabled if internal::StringView is an alias for std::string_view to avoid multiple definitions with the same overload. Simply omitting the unconditional PrintTo(std::string_view) overload is a worse option though, as this results in std::string_view not printing nicely if internal::StringView is not an alias for std::string_view. PiperOrigin-RevId: 762020327 Change-Id: I92f5bdbacba89e97bbcc0fef3ca9261ea5a788d3
* | Try to warn the user when test filters do not match any testsDerek Mauro2025-02-282-0/+39
| | | | | | | | | | PiperOrigin-RevId: 732204780 Change-Id: I2c4ccabd123e3b79c3dd8bc768a4cd9a576d282c
* | Output to the test warning file if no tests are linked.Derek Mauro2025-02-261-5/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | Bazel sets the environment variable TEST_WARNINGS_OUTPUT_FILE https://bazel.build/reference/test-encyclopedia#initial-conditions If no tests are linked and the new flag --gtest_fail_if_no_test_linked is not true (which is the current default), we can still warn the user as this may be a programming error without failing the test (which would break existing users). PiperOrigin-RevId: 731402363 Change-Id: Ia481689efd4bd18889feaaa38bc56049a3f651cd
* | Adds support for a --gtest_fail_if_no_test_linked flagZhanyong Wan2025-02-241-0/+15
| | | | | | | | | | | | | | | | to fail the test program if no test case is linked in (a common programmer mistake). PiperOrigin-RevId: 730571311 Change-Id: I1dab04adfe35581274d0b4ec79a017014d50e1ea
* | Export testsuite properties as XML elements, not attributes.Abseil Team2025-01-311-27/+11
|/ | | | | | | | With this change, arbitrary property names in the testsuite no longer cause the produced XML output to be ill-formed. PiperOrigin-RevId: 721549090 Change-Id: Iedffa89bf914478f563c8f3b82cd50557762a665
* gtest: Output a canned test case for test suite setup / teardown failures in ↵Abseil Team2024-12-261-6/+44
| | | | | | | | | | | XML/JSON This surfaces useful information about the environment failure in a structured form. As we can see from the updated test, previously unsurfaced information is now present. PiperOrigin-RevId: 709892315 Change-Id: I2656294d50c33f995bef5c96195a66cff3c4b907
* This change adjusts how `ASSERT_NEAR` and `EXPECT_NEAR` treats infinity, ↵Abseil Team2024-10-141-1/+16
| | | | | | | | | | | | | | such that `ASSERT_NEAR(inf, inf, 0)` passes. This makes the behavior more consistent with `ASSERT_EQ(inf, inf)` which succeeds. Some examples of asserts that now pass: ``` ASSERT_NEAR(inf, inf, 0) ASSERT_NEAR(-inf, inf, inf) ASSERT_NEAR(inf, x, inf) // x is any finite floating point value ``` PiperOrigin-RevId: 685748133 Change-Id: I7b3af377773e8e0031e4c6b86830cbbf76bf20c6
* Add a bounds check to protect against an empty vector from GetArgs(), whichAbseil Team2024-06-281-2/+5
| | | | | | | | can cause an out of bounds access in GetCurrentExecutableName(). One way this can happen is if the user forgets to call InitGoogleTest(). PiperOrigin-RevId: 647740658 Change-Id: Id87692aa3d515b8ae0836e474be477d2aafa3871
* Change GoogleTest flag removal to not read beyond the end of the arrayDerek Mauro2024-05-211-6/+6
| | | | | | | | | | | to the NULL terminator. #4532 says ASAN complains about this on some platforms, although it is not clear if ASAN or the platform implementation is incorrect about accessing the terminating NULL. Fixes #4532 PiperOrigin-RevId: 635886009 Change-Id: Ibb4237055488c895b1dd09145ab979347bb9a390
* Merge pull request #4508 from davidmatson:addJsonSkippedCopybara-Service2024-04-081-16/+43
|\ | | | | | | | | PiperOrigin-RevId: 622929007 Change-Id: Ifaf5a701baee74503e6845f32ebc27425882e950
| * Add skipped messages to JSON output (fixes #4507).refs/pull/4508/headDavid Matson2024-04-031-16/+41
| | | | | | | | Fix the gap between JSON and XML output.
* | Merge pull request #4505 from to01z:add-winapi-partition-games-supportCopybara-Service2024-04-032-17/+17
|\ \ | | | | | | | | | | | | PiperOrigin-RevId: 621631167 Change-Id: I0790f7082ce3c20fef92958c820d40ec854fe91d
| * | Add support for compiling GoogleTest for XboxTroels Gram2024-03-242-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for Xbox platforms, requires the code to support compilation with the WINAPI_FAMILY_GAMES subset of the Win32 API. - Add support for WINAPI_FAMILY_GAMES to enable GTEST_OS_WINDOWS_GAMES platform. - Disable stream redirection (GTEST_HAS_STREAM_REDIRECTION = 0) and colored TTY printing for GTEST_OS_WINDOWS_GAMES platform. Both features currently require Win32 functions that don't exist in the WINAPI_FAMILY_GAMES subset. Misc fixes: - gtest-port.cc: Move GTEST_DISABLE_MSC_DEPRECATED_PUSH_ into GTEST_HAS_STREAM_REDIRECTION conditional section where the corresponding GTEST_DISABLE_MSC_DEPRECATED_POP_ is located. - googletest-port-test.cc: Switch stream redirection tests to be conditional on GTEST_HAS_STREAM_REDIRECTION instead of !defined(GTEST_OS_WINDOWS_MOBILE).
* | | Fix a race condition between the Watcher thread and the main threadDerek Mauro2024-04-031-10/+25
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | during program exit A race condition exist between the Watcher thread and main(). A case was found where the Watcher thread does not get execution time before the main function returns and calls atexit(). At that point the Watcher thread started runing tls_init() code while the main thread was shutting down. This resulted in rare crashes and deadlocks. Fixes #4493 Closes #4494 PiperOrigin-RevId: 621619768 Change-Id: I66f00d8f0f3c37f9937c6d13890f7fa10038256d
* | Merge pull request #4503 from davidmatson:fixTypoCopybara-Service2024-04-021-1/+1
|\ \ | | | | | | | | | | | | PiperOrigin-RevId: 621334548 Change-Id: I19747f832b51cc5bbb0231bbd9416a8373e4aa77
| * | Fix typo in comment.refs/pull/4503/headDavid Matson2024-03-291-1/+1
| |/
* | Merge pull request #4502 from davidmatson:fixStreamHelpTextOsCopybara-Service2024-04-021-1/+1
|\ \ | |/ |/| | | | | PiperOrigin-RevId: 621172364 Change-Id: Ibaacb17c60b5ee0e58c3689b79aa2cd6b49dc1c4
| * Fix help text for stream_result_to flag.refs/pull/4502/headDavid Matson2024-03-281-1/+1
|/ | | | | Support for Mac was previously added, in addition to Linux. Fix the help text to match the code.
* Merge pull request #4490 from memdo:mainCopybara-Service2024-03-181-7/+6
|\ | | | | | | | | PiperOrigin-RevId: 616931521 Change-Id: Iffbb24e3f9add4e7acf8f1988a03afc8628b0733
| * Add colored output support for Alacrittyrefs/pull/4490/headMustafa Berkay Düzenli2024-03-151-0/+1
|/
* Reland: Optimize Google Test process startupAbseil Team2024-03-082-53/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Google Test performs hidden test registration during process startup. For test binaries that contain a large number of tests, this registration can be costly. In this CL, we reduce the overhead of registration via several tactics: - Treat CodeLocation and FilePath as value types, using std::move to pass them around. - Reduce string copies in various places by either passing std::string values via std::move, or passing const-refs to std::string instances. - Use std::to_string to stringify an int in DefaultParamName rather than a std::stringstream. - Pull some std::string instances out of nested loops in ParameterizedTestSuiteInfo::RegisterTests so as to reuse some allocations, and replace stringstream with ordinary string appends. - Use std::unordered_map in UnitTestImpl::GetTestSuite and ParameterizedTestSuiteRegistry::GetTestSuitePatternHolder to spend a little memory to turn O(N) lookups into constant time lookpus. - Use range-based for loops in a few places. - Use emplace-ish methods to add to containers where appropriate. All together, these changes reduce the overall runtime of a series of 50 death tests in a single Chromium test executable by ~38% due to the fact that the registration costs are paid in every death test's child process. PiperOrigin-RevId: 613833210 Change-Id: I51a262a770edff98ffa1e3b60c4d78a8308f9a9f
* Revert Optimize Google Test process startupAbseil Team2024-03-052-66/+71
| | | | | PiperOrigin-RevId: 612878184 Change-Id: Ia8e23da1ad09c2e0ce635a855f0c250f368f6878
* Optimize Google Test process startupAbseil Team2024-03-052-71/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Google Test performs hidden test registration during process startup. For test binaries that contain a large number of tests, this registration can be costly. In this CL, we reduce the overhead of registration via several tactics: - Treat CodeLocation and FilePath as value types, using std::move to pass them around. - Reduce string copies in various places by either passing std::string values via std::move, or passing const-refs to std::string instances. - Use std::to_string to stringify an int in DefaultParamName rather than a std::stringstream. - Pull some std::string instances out of nested loops in ParameterizedTestSuiteInfo::RegisterTests so as to reuse some allocations, and replace stringstream with ordinary string appends. - Use std::unordered_map in UnitTestImpl::GetTestSuite and ParameterizedTestSuiteRegistry::GetTestSuitePatternHolder to spend a little memory to turn O(N) lookups into constant time lookpus. - Use range-based for loops in various places. - Use emplace-ish methods to add to containers where appropriate. All together, these changes reduce the overall runtime of a series of 50 death tests in a single Chromium test executable by ~38% due to the fact that the registration costs are paid in every death test's child process. PiperOrigin-RevId: 612763676 Change-Id: I1f46e012ccb9004c009e1027e4f7c38780ffb9e2
* Merge pull request #4477 from tmiguelf:feature/soup_cleanupCopybara-Service2024-02-281-10/+10
|\ | | | | | | | | PiperOrigin-RevId: 611133343 Change-Id: Ieef806f51fcbc2877805dae415f76d03547b8dfa
| * Fixed gcc linker error 58refs/pull/4477/headTiago Freire2024-02-231-10/+20
| |
* | Make sure that current_test_suite and current_test_info are mutex-protected ↵Abseil Team2024-02-272-30/+43
|/ | | | | | | while writing for thread-safety. PiperOrigin-RevId: 610810340 Change-Id: I37f33510373dff04b8e9c9e8a9f32d30fcce46ff
* Use _Exit instead of _exit in GoogleTestAbseil Team2024-02-071-6/+8
| | | | | | | | _Exit is standardized since C99, whereas _exit is POSIX-only. Fixes: #4447 PiperOrigin-RevId: 605000352 Change-Id: Ibfa84edaa043bd003a21383e8148bf45be7217f6
* Destroy installed environments in normal code, not in static teardown.Abseil Team2024-02-071-3/+12
| | | | | | | | | | | Destruction in static teardown causes issues for Environments which own threads and try to join them in their destruction. This may be a breaking change for users who call RUN_ALL_TESTS multiple times in the same main function if they also install environments, or those who access registered environments after RUN_ALL_TESTS. The easiest fix is to only call RUN_ALL_TESTS once as the last line of the main function. Another potential fix is to re-register new instances of the Environment once before each call to RUN_ALL_TESTS. PiperOrigin-RevId: 604800795 Change-Id: I37c44d4aca4a238052649f45a4b6b9cfb5355b71
* Do not emit stack traces for messages generated by SUCCEED()Abseil Team2024-01-301-4/+14
| | | | | | | | | | | | | | | | | | | | | | | Stack traces in assertion failures are an extremely useful tool for developers tasked with investigating failing tests. It's difficult to understate this. In contrast to ordinary test assertions (e.g., ASSERT_TRUE or EXPECT_FALSE), SUCCEED() is a developer-authored directive that indicates a success codepath. In fact, the documentation states that this directive doesn't generate any output. Generating stack traces for uses of SUCCEED() is wasted work since they are never printed. If this were to change one day in the future, they still would not be useful since any emitted message would include the file and line number where SUCCEED was used. In addition to being noise in the output in this case, symbolization of stack traces is not free. In some Chromium configurations, symbolization for use of SUCCEED() can incur a cost in excess of 25 seconds for a test that otherwise takes 0-1ms; see https://crbug.com/1517343. In this CL, we suppress generation and emission of stack traces for kSuccess messages to reduce the overhead of SUCCEED(). PiperOrigin-RevId: 602832162 Change-Id: I557dd6a1d3e6ed6562daf727d69fd01fe914827b
* If GTEST_NO_ABSL_FLAGS is #defined, then the Abseil flag libraryAbseil Team2024-01-181-1/+7
| | | | | | | will not be used by googletest, even if GTEST_HAS_ABSL is #defined. PiperOrigin-RevId: 599625032 Change-Id: Ieb994a15683dec89e88578120071eca8ac9fead1
* Make posix::FileNo available under !GTEST_HAS_FILE_SYSTEMAbseil Team2024-01-161-4/+2
| | | | | | | | This enables automatic color output without filesystem support, as that only requires testing to see if the output is a terminal. Fixes: #4439 PiperOrigin-RevId: 598929397 Change-Id: Idca7490e6e090951a78cd1cdd710f41d756a68b4
* Do not emit stack traces for messages generated by GTEST_SKIP()Abseil Team2024-01-161-1/+6
| | | | | | | | | | | | | | | | | | | | Stack traces in assertion failures are an extremely useful tool for developers tasked with investigating failing tests. It's difficult to understate this. In contrast to ordinary test assertions (e.g., ASSERT_TRUE or EXPECT_FALSE), GTEST_SKIP is a developer-authored directive to skip one or more tests. Stack traces emitted in skip messages do not give the developer useful information, as the skip message itself contains the code location where GTEST_SKIP was used. In addition to being noise in the output, symbolization of stack traces is not free. In some Chromium configurations, symbolization in a skipped test can incur a cost in excess of 25 seconds for a test that otherwise takes 0-1ms; see https://crbug.com/1517343#c9. In this CL, we suppress generation and emission of stack traces for kSkip messages to reduce the output noise and overhead of GTEST_SKIP(). PiperOrigin-RevId: 598899010 Change-Id: I46926fed452c8d7edcb3d636d8fed42cb6c0a9e9
* Remove unnecessary conversionTom Hughes2023-12-121-2/+2
| | | | | | | | `GetAbsolutePathToOutputFile` returns a `std::string` and `OpenFileForWriting` takes a `std::string&`. PiperOrigin-RevId: 589984409 Change-Id: I75be9cb105f49b3a279a5d33b1b82dfcfc912cfd
* Merge pull request #4397 from botovq:raiseCopybara-Service2023-10-301-0/+1
|\ | | | | | | | | PiperOrigin-RevId: 577958594 Change-Id: I8a27f67dc5b6817b741bfd2fc0f27c6302291a00
| * Add missing include for raise(3)refs/pull/4397/headTheo Buehler2023-10-251-0/+1
|/ | | | | | If SIGTRAP is defined, this file may end up using raise(3), which is defined in csignal, leading to a compilation failure on at least OpenBSD/sparc64 with gcc 8.
* Fix RE::Init for Android and NetBSD.Abseil Team2023-10-051-2/+13
| | | | | | | | | This is a somewhat recent change for Android (I'm not clear on whether it's a recent change for NetBSD, or if Android was just very behind on its implementation), so while this worked fine as recently as API 32 devices, REG_GNU is required for API 34 (API 33 untested). A test actually caught this, but https://github.com/google/googletest/pull/4334 "fixed" the test rather than the implementation. This CL also reverts the test change so it can catch the failure. PiperOrigin-RevId: 571126374 Change-Id: I420dfcedea58f2c8b605f699515d744006c0a9d9
* Use the `empty()` method to check for emptiness instead of `length()`Abseil Team2023-09-182-2/+2
| | | | | PiperOrigin-RevId: 566247438 Change-Id: I8199ef53310a057abbe23f8f4295507b60d6b707
* Merge pull request #4342 from tanzislam:prefer-tmpdir-on-androidCopybara-Service2023-09-141-8/+24
|\ | | | | | | | | PiperOrigin-RevId: 565230380 Change-Id: I6e91eea46d05413d4d87e73a11941786604d9f27
| * Reuse TempDir() functionrefs/pull/4342/headTanzinul Islam2023-08-261-4/+1
| |
| * Prefer $TMPDIR to /data/local/tmp on AndroidTanzinul Islam2023-08-181-1/+7
| | | | | | Newer devices can have the latter location read-only. (I observed this with Termux on a non-rooted Pixel 6.)
* | changed http to httpsrefs/pull/4349/headsthd2023-08-223-3/+3
| |
* | Merge pull request #4322 from pgawro:ansi_colorsCopybara-Service2023-08-181-1/+2
|\ \ | |/ |/| | | | | PiperOrigin-RevId: 558224853 Change-Id: Ib2d8ad41fcc4d38f58aa5702b537467d8867d82e
| * googletest: ansi color fixrefs/pull/4322/headPatryk Gawroński2023-08-161-1/+2
| | | | | | | | | | | | | | Adds prevents from returning nullptr by choosing default color. Issue: #4321
* | Use #if and not #ifdef to check filesystem supportrefs/pull/4325/headJulien Combattelli2023-07-291-1/+1
|/