summaryrefslogtreecommitdiffstats
path: root/googletest/src/gtest.cc
Commit message (Collapse)AuthorAgeFilesLines
* 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-031-7/+7
|\ \ | |/ |/| | | | | PiperOrigin-RevId: 621631167 Change-Id: I0790f7082ce3c20fef92958c820d40ec854fe91d
| * Add support for compiling GoogleTest for XboxTroels Gram2024-03-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | 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-081-49/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-051-50/+67
| | | | | PiperOrigin-RevId: 612878184 Change-Id: Ia8e23da1ad09c2e0ce635a855f0c250f368f6878
* Optimize Google Test process startupAbseil Team2024-03-051-67/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make sure that current_test_suite and current_test_info are mutex-protected ↵Abseil Team2024-02-271-18/+31
| | | | | | | while writing for thread-safety. PiperOrigin-RevId: 610810340 Change-Id: I37f33510373dff04b8e9c9e8a9f32d30fcce46ff
* 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.
* Use the `empty()` method to check for emptiness instead of `length()`Abseil Team2023-09-181-1/+1
| | | | | PiperOrigin-RevId: 566247438 Change-Id: I8199ef53310a057abbe23f8f4295507b60d6b707
* changed http to httpsrefs/pull/4349/headsthd2023-08-221-1/+1
|
* 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
* Make GoogleTest handle SEH exceptions before stack unwinding rather than ↵Abseil Team2023-06-301-43/+24
| | | | | | | | | | | afterward This ensure the erroring stack frame is visible and accessible when the handler is invoked. Fixes #4298 PiperOrigin-RevId: 544692549 Change-Id: Ia165a8c293e8edc820da5f5ad4416546fffe2493
* Print stack traces on SEH exceptions on WindowsAbseil Team2023-06-281-18/+21
| | | | | | | | | | | | Also tidies up a couple of things: - Prevent handling of stack overflows, which cannot be done safely - `exception_code` is a macro, so we rename it - The `std::string` heap allocation was unnecessary Fixes #4298 PiperOrigin-RevId: 544117790 Change-Id: I8ba61f87119d5fbdb1f653700d9867ca6f8c28ce
* On platforms without a file system, don't log an error when noDerek Mauro2023-06-281-2/+4
| | | | | | | | | alternative output format is requested. Fixes #4299 PiperOrigin-RevId: 543932266 Change-Id: Ide78c313ecf6829e4910f4a8407275c81edb3848
* Allow clients to un-suppress output from gUnit EXPECT_EXIT tests.Abseil Team2023-06-151-3/+3
| | | | | | | | This is useful for running individual tests in a separate process, which is useful for testing e.g. flag changes which have a process-global effect. PiperOrigin-RevId: 540580573 Change-Id: I18a5d24d79425a9d595be3369efc44e2f655f6f8
* Skip entire test suite with `GTEST_SKIP()` in `SetUpTestSuite`Dino Radakovic2023-06-141-1/+2
| | | | | | | Fixes #4273 PiperOrigin-RevId: 540254167 Change-Id: I2555740d10284223539035bf73f88554fcf73f8a
* Use Abseil Flag public API for flag parsing.Abseil Team2023-04-261-15/+54
| | | | | | | This change brings InitGoogleTest semantic in accordance with the official documentation: only GoogleTest flags are removed from argc/argv. The rest of the flags remains in place. We do nothing special for flags with unrecognized gunit_/gtest_ prefix and we do not report them. PiperOrigin-RevId: 527257221 Change-Id: Ibb29a1bda1a44251a4ee579c0fb5bbdfd9965c21
* Use '=default' to define trivial constructor/destructorsrefs/pull/4221/headTom Hughes2023-04-211-4/+4
| | | | | | | https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html PiperOrigin-RevId: 526079054 Change-Id: Ia4db21e3e5f58b90de05d52fd94b291ed06d785d
* Add missing std includesTom Hughes2023-04-201-0/+3
| | | | | PiperOrigin-RevId: 525850646 Change-Id: I64387f5b933beb79cd05636dca81b7a75213383e
* Make parameter names in function declaration match the names in theTom Hughes2023-04-201-10/+10
| | | | | | | | | definitions https://clang.llvm.org/extra/clang-tidy/checks/readability/inconsistent-declaration-parameter-name.html PiperOrigin-RevId: 525752102 Change-Id: Ibf9d3d1dbae8f95cfc7c6ad29fe4b677f4ee19cf
* gtest.cc: run tests within a test suite in a deterministic order.Abseil Team2023-04-051-0/+20
| | | | | | | | | Ensure that tests are run in the order specified in the source code, even if they are registered manually using RegisterTest. There should be no behavior change for the common case. PiperOrigin-RevId: 522136303 Change-Id: If155e2666780af0e514fbbf5ff2b157d5fe2fef1
* Rolled back due to breaking existing tests.Abseil Team2023-04-031-20/+0
| | | | | PiperOrigin-RevId: 521555658 Change-Id: I09742faceb82b2b7ceb423e850a8b50d532ad6ff
* gtest.cc: run tests within a test suite in a deterministic order.Aaron Jacobs2023-03-301-0/+20
| | | | | | | | | Ensure that tests are run in the order specified in the source code, even if they are registered manually using RegisterTest. There should be no behavior change for the common case. PiperOrigin-RevId: 520729483 Change-Id: I400c78400c6929fccae0676214d993251f31888f
* Internal Code ChangeAbseil Team2023-03-231-6/+5
| | | | | PiperOrigin-RevId: 518810140 Change-Id: Id3f9471f827894761080bc9199b0a092dc829b5f
* gtest.cc: add a newline after a failure when there is no OS stack trace.Aaron Jacobs2023-03-231-0/+2
| | | | | | | | This makes the behavior consistent when GTEST_STACK_TRACE_DEPTH is set to zero and not: there is always vertical whitespace separating failure messages. PiperOrigin-RevId: 518744611 Change-Id: I5b4af40633849850660504c3f497a76601d4311d
* Remove GTEST_FOR_GOOGLE_ macroTom Hughes2023-03-061-4/+0
| | | | | | | | The "more details" warning message printed by this macro is no longer needed. PiperOrigin-RevId: 513945729 Change-Id: I644910216dbef2fe92eee3a648f2078e705cc7a1
* Replace "#if GTEST_HAS_ABSL" with "#ifdef GTEST_HAS_ABSL"Tom Hughes2023-03-061-6/+6
| | | | | | | This allows compilation with "-Wundef" (#3267). PiperOrigin-RevId: 513945230 Change-Id: I45ef19c7ff3d20e97216bd031d406a03365471da
* Use "#ifdef" with public macrosTom Hughes2023-03-061-6/+6
| | | | | | | This allows compilation with "-Wundef" (#3267). PiperOrigin-RevId: 513944726 Change-Id: I1a3854bb2333d5dec6c0ff91ee1eddd9a766ab91
* Use "#ifdef GTEST_OS_..." instead of "#if GTEST_OS_..."Tom Hughes2023-03-061-31/+36
| | | | | | | This is compatible with compiling with "-Wundef" (#3267). PiperOrigin-RevId: 513943378 Change-Id: I47cf5fabbb77be061c4483a0adc54511af6b191c
* Eliminate argv list action parameter.Abseil Team2023-02-281-2/+1
| | | | | PiperOrigin-RevId: 512791992 Change-Id: Ie7fc37ea06ea7d9f595268c9ec84a0e144c297bb
* Merge pull request #4164 from sergio-nsk:patch-2Copybara-Service2023-02-271-0/+4
|\ | | | | | | | | PiperOrigin-RevId: 512753220 Change-Id: I3f7ad6c62c738d1d7405c50924b36deac8a9ac85
| * Fix error in_death_test_child_process: undeclared identifierrefs/pull/4164/headSergey2023-02-211-0/+3
|/ | | The error occurs if !GTEST_HAS_DEATH_TEST on Windows.
* Remove some filesystem APIs and tests under !GTEST_HAS_FILE_SYSTEMAbseil Team2023-02-141-1/+6
| | | | | PiperOrigin-RevId: 509537606 Change-Id: I68f7054e34b1fe76c1fd85099fffa4ee3c2b00c0