summaryrefslogtreecommitdiffstats
path: root/googletest/test
Commit message (Collapse)AuthorAgeFilesLines
* Add rules_cc dependency, required by Bazel going forwardHEADmainDerek Mauro9 days1-0/+1
| | | | | | | | | This also adds the dependencies of rules_cc to WORKSPACE. bzlmod automatically pulls in dependencies. skylib is removed as it is pulled in by a deps function. PiperOrigin-RevId: 808659470 Change-Id: Idc41cad7b05019793d4a1898bdb80bc4797da5cf
* Update spelling of Mutex::lock and Mutex::unlock for compatibilityDerek Mauro2025-09-121-2/+2
| | | | | | | with the standard and the latest Abseil PiperOrigin-RevId: 806260850 Change-Id: Ie973be4a3aaf7e174cd692ce6df7a82c8f261bf7
* Skip the predicate on SIGSEGV in death-test on Android builds with API level ↵Abseil Team2025-07-231-1/+1
| | | | | | | <= 23. PiperOrigin-RevId: 786394374 Change-Id: I5188b55ae8ae6d3188e6492f3865b21ae6d2285e
* Merge pull request #4694 from chromy:mainCopybara-Service2025-06-252-0/+4
|\ | | | | | | | | PiperOrigin-RevId: 775667059 Change-Id: I07edd44ae368ae640d7b985800ffee8cc663c07f
| * Default to color output for ghosttyrefs/pull/4694/headHector Dearman2025-01-102-0/+4
| |
* | googletest: Add a flag to fail if no tests were selected to run.David Pizzuto2025-06-092-5/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-302-6/+6
| | | | | | | | | | | | | | | | 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-0/+16
| | | | | | | | | | | | | | | | | | 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-5/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Delete the absl polyfill support for std::any, std::optionalDerek Mauro2025-05-201-13/+10
| | | | | | | | | | | | | | | | and std::variant now that the absl types are aliases of the std types PiperOrigin-RevId: 761136061 Change-Id: I702c3e1e8c58d003b8f4da99e7c84c9e5dbe1863
* | Add [[nodiscard]] to GetParam() to prevent accidental misuse.Mike Kruskal2025-05-141-1/+1
| | | | | | | | | | | | | | This helps avoid a situation where someone sets up a parameterized test but forgets to actually use the parameter. PiperOrigin-RevId: 758455362 Change-Id: Ie4db03e82b6a4e1787be96f154b3fbb25657ae64
* | Add a `testing::ConvertGenerator` overload that accepts a converting ↵Abseil Team2025-03-041-0/+70
| | | | | | | | | | | | | | functor. This allows the use of classes that do not have a converting ctor to the desired type. PiperOrigin-RevId: 733383835 Change-Id: I6fbf79db0509b3d4fe8305a83ed47fceaa820e47
* | Try to warn the user when test filters do not match any testsDerek Mauro2025-02-281-0/+19
| | | | | | | | | | PiperOrigin-RevId: 732204780 Change-Id: I2c4ccabd123e3b79c3dd8bc768a4cd9a576d282c
* | Output to the test warning file if no tests are linked.Derek Mauro2025-02-261-5/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-244-16/+241
| | | | | | | | | | | | | | | | to fail the test program if no test case is linked in (a common programmer mistake). PiperOrigin-RevId: 730571311 Change-Id: I1dab04adfe35581274d0b4ec79a017014d50e1ea
* | GoogleTest C++17 cleanupsDerek Mauro2025-02-211-4/+3
| | | | | | | | | | | | | | | | | | | | * Use `[[nodiscard]]` instead of GTEST_MUST_USE_RESULT_ * Use `[[maybe_unused]]` instead of GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED * Use `[[deprecated]]` instead of `GTEST_INTERNAL_DEPRECATED` * Remove `GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL` PiperOrigin-RevId: 729523519 Change-Id: Ia1b901cf9c0a0e148eec419ada0e0b56aba2dd3d
* | Require C++17Derek Mauro2025-02-122-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Policy information: https://opensource.google/documentation/policies/cplusplus-support#c_language_standard https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md Some small fixes are included for C++17 compatibility. We had no tests for MSVC C++17 or C++20, so those tests that failed and had no obvious fix are disabled and a tracking bug has been filed. PiperOrigin-RevId: 726090558 Change-Id: I4d37d47e87c11f85bfd572deb10f67ca3eb2a9b5
* | Remove empty glob pattern, which is now an error.Derek Mauro2025-02-061-1/+0
| | | | | | | | | | | | | | It look like this may be a copy-paste bug from the root BUILD file. PiperOrigin-RevId: 724062332 Change-Id: I8eda2275d996dd14693aee569254db28d9bc4f9d
* | Export testsuite properties as XML elements, not attributes.Abseil Team2025-01-313-61/+69
|/ | | | | | | | 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-263-22/+154
| | | | | | | | | | | 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
* Add support for printing C++20 std::*_ordering types to gtest.Abseil Team2024-12-101-0/+24
| | | | | | | | Adds feature test macro for C++20 <compare> header, a pretty-printer, and tests. Inexplicably, these types aren't enums, so can't be handled with a switch. PiperOrigin-RevId: 704783038 Change-Id: I29688989d18f43520fe610c12a447a20d2f98c95
* This change adjusts how `ASSERT_NEAR` and `EXPECT_NEAR` treats infinity, ↵Abseil Team2024-10-141-0/+49
| | | | | | | | | | | | | | 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
* Skip the predicate on SIGSEGV in death-test on Android builds with API level ↵Abseil Team2024-06-131-0/+2
| | | | | | | <= 21. PiperOrigin-RevId: 643076477 Change-Id: Id9486b7d73c3b17851df1eaf8f5ab2085238bf75
* Use `[[maybe_unused]]` when it is available to avoidDerek Mauro2024-04-161-3/+4
| | | | | | | -Wused-but-marked-unused warnings PiperOrigin-RevId: 625430612 Change-Id: Ia9d2e47984e1e6f91966afae8a6750119ae69446
* Merge pull request #4508 from davidmatson:addJsonSkippedCopybara-Service2024-04-082-0/+18
|\ | | | | | | | | PiperOrigin-RevId: 622929007 Change-Id: Ifaf5a701baee74503e6845f32ebc27425882e950
| * Add skipped messages to JSON output (fixes #4507).refs/pull/4508/headDavid Matson2024-04-032-0/+21
| | | | | | | | Fix the gap between JSON and XML output.
* | [gtest] Use `std::index_sequence` and friends instead of rolling our ownLawrence Wolf-Sonkin2024-04-041-16/+0
|/ | | | | | | | | * Applies for `std::index_sequence`, `std::make_index_sequence`, and `std::index_sequence_for` replacing `IndexSequence`, `MakeIndexSequence` and IndexSequenceFor` * Also deleted implementation helper `DoubleSequence` * The standard interfaces [have been in the standard library since C++14](https://en.cppreference.com/w/cpp/utility/integer_sequence), which [is the minimum supported C++ version by Google Test](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md) PiperOrigin-RevId: 621939977 Change-Id: Id264266f08da66c0fa2a6e6fbb8f86fd3cb3a421
* Merge pull request #4490 from memdo:mainCopybara-Service2024-03-182-3/+7
|\ | | | | | | | | PiperOrigin-RevId: 616931521 Change-Id: Iffbb24e3f9add4e7acf8f1988a03afc8628b0733
| * Add colored output support for Alacrittyrefs/pull/4490/headMustafa Berkay Düzenli2024-03-152-0/+4
|/
* Use _Exit instead of _exit in GoogleTestAbseil Team2024-02-071-37/+39
| | | | | | | | _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-072-47/+53
| | | | | | | | | | | 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
* Modifications to improve portability of googletest tests.Abseil Team2024-01-312-5/+12
| | | | | PiperOrigin-RevId: 603034597 Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
* Do not emit stack traces for messages generated by SUCCEED()Abseil Team2024-01-301-4/+0
| | | | | | | | | | | | | | | | | | | | | | | 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
* Do not emit stack traces for messages generated by GTEST_SKIP()Abseil Team2024-01-162-7/+9
| | | | | | | | | | | | | | | | | | | | 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
* Fix RE::Init for Android and NetBSD.Abseil Team2023-10-051-2/+2
| | | | | | | | | 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
* Count threads after thread-creation while still holding mutex lockrefs/pull/4365/headTanzinul Islam2023-09-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `Mutex` is locked with the `MutexLock` before spawning the thread, so that the thread is prevented from completing (by being blocked on `Mutex`) before the new thread count is obtained. However, the existing bug (introduced in 22e6055) releases `Mutex` before obtaining the new thread count, which allows the thread to run to completion in the meantime. Also, since the `(thread_count_after_create != starting_count + 1)` condition (line 328) skips the remainder of the `for`-loop body on every iteration, `thread_count_after_join` stays uninitialized. I believe this is why [this test failed][1] on the macOS CI with this trace: ``` [----------] 1 test from GetThreadCountTest [ RUN ] GetThreadCountTest.ReturnsCorrectValue googletest/test/googletest-port-test.cc:350: Failure Expected equality of these values: thread_count_after_create Which is: 1 starting_count + 1 Which is: 2 googletest/test/googletest-port-test.cc:351: Failure Expected equality of these values: thread_count_after_join Which is: 140493185949400 starting_count Which is: 1 [ FAILED ] GetThreadCountTest.ReturnsCorrectValue (2 ms) [----------] 1 test from GetThreadCountTest (2 ms total) ``` [1]: https://github.com/google/googletest/actions/runs/6064919420/job/16453860690?pr=3049
* googletest: Add universal printer for `std::span`Dino Radakovic2023-08-251-0/+16
| | | | | | | Fixes #4318 PiperOrigin-RevId: 560089120 Change-Id: I9d0d098140033520266747a1689e953ee8307c47
* Merge pull request #4333 from ngie-eign:gtest_help_test-fix-FreeBSDCopybara-Service2023-08-151-3/+14
|\ | | | | | | | | PiperOrigin-RevId: 557197748 Change-Id: I55b86353f5351bbcbdf8e6bca70e82d7383a5080
| * Fix GTestHelpTest.TestHelpFlag on FreeBSDrefs/pull/4333/headEnji Cooper2023-08-081-3/+13
| | | | | | | | | | | | | | | | | | The test supported a variety of BSDs, including kFreeBSD, but not FreeBSD. Move the BSD checks to a separate function and support checking for FreeBSD, in addition to kFreeBSD. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
* | gtest_help_test: Make method names `snake_case`, conforming with [the style ↵Dino Radakovic2023-08-151-7/+7
| | | | | | | | | | | | | | guide](https://google.github.io/styleguide/pyguide#316-naming) PiperOrigin-RevId: 557133618 Change-Id: I27202ee91ee81b3d2e4c28102190d2bde8efba05
* | gtest_help_test: Inline test helper functionsDino Radakovic2023-08-151-23/+7
| | | | | | | | | | | | | | `TestNonHelpFlag` is only a few asserts with no logic, which is easier to read in line, and helper `TestHelpFlag` is used in a single test case. PiperOrigin-RevId: 557122793 Change-Id: I7367424abfbb883c10c260fae066a2071e5dfa0e
* | Merge pull request #4334 from ngie-eign:fix-RETest-non-ABSLCopybara-Service2023-08-151-2/+2
|\ \ | | | | | | | | | | | | PiperOrigin-RevId: 557122083 Change-Id: I77fb7fe99baf9cbf341ad37d4b651a0ac606b549
| * | Fix RETest/1.ImplicitConstructorWorks on non-ABSL platformsrefs/pull/4334/headEnji Cooper2023-08-081-2/+2
| |/ | | | | | | | | | | | | | | The last regular expression specified in the test is not technically POSIX compatible. Use `[[:alnum:]_]` instead of `\w+`; the latter is a Perl-compatible regular expression. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
* | gtest_help_test: Delete obsolete helper `TestUnknownFlagWithAbseil`Dino Radakovic2023-08-151-13/+0
|/ | | | | PiperOrigin-RevId: 557116814 Change-Id: I91e06b0d6001952366c50201b67491475a1f98af
* Merge pull request #4323 from ↵Copybara-Service2023-08-031-1/+1
|\ | | | | | | | | | | | | pgawro:gtest_ExpectThrowTest_DoesNotGenerateUnreachableCodeWarning PiperOrigin-RevId: 553485739 Change-Id: I6581215e6db514397177af39381eea4d121f32bd
| * gtest: Supress warning about set unused variablerefs/pull/4323/headPatryk Gawroński2023-07-261-1/+1
| | | | | | | | Modified test ExpectThrowTest.DoesNotGenerateUnreachableCodeWarning
* | Add googletest-message-test to the Bazel testsDerek Mauro2023-08-021-0/+1
| | | | | | | | | | | | | | It appears to have been unintentionally left out PiperOrigin-RevId: 553141410 Change-Id: I8adac55a3df0ec12d6fe03446f71858fc702e178
* | Make testing::Message support streamed AbslStringify valuesPhoebe Liang2023-08-011-0/+23
|/ | | | | | | This allows types that provide an AbslStringify definition to be streamed into GoogleTest macros. PiperOrigin-RevId: 552914482 Change-Id: I5fb386980d4d24873f95f0a8ef83067a6a3c86ac
* Make `AbslStringify` usage public in GoogleTestAbseil Team2023-07-211-0/+28
| | | | | | | Fixes #4314 PiperOrigin-RevId: 549986457 Change-Id: Iff74f02ab1c106696f288540e9c623d56b76e3f7
* Resolve an issue where the resolution of `operator<<` overloads would ↵Abseil Team2023-06-271-0/+16
| | | | | | | attempt to instantiate the incomplete `testing::internal::Secret` type. PiperOrigin-RevId: 543799815 Change-Id: Ic0a4f48d825bef26cb8cc74d8a0117b3a5ef3f14