Fix `-Wgnu-zero-variadic-macro-arguments` in GMock
Passing zero arguments to the variadic part of a macro is a GNU
extension and triggers warnings when build projects using GMock with
`-pedantic`.
- Fix uses of `GMOCK_PP_INTERNAL_16TH` to always receive at least 17
arguments. (this was triggered when `GMOCK_PP_NARG` or `GMOCK_PP_HAS_COMMA`
were used with an argument containing no commas).
- Fix `GMOCK_PP_HEAD` to append a dummy unused argument so that
`GMOCK_PP_INTERNAL_HEAD` always has two arguments.
PiperOrigin-RevId: 310414611
While the google test library is being built as a shared library using Bazel,
so that there is a rule like
cc_test(
name = "iterator_traits_test",
linkstatic = 0,
deps = ["@gtest//:gtest_main"],
...
)
in a BUILD file, the following error appears on Windows:
INFO: Found 1 test target...
ERROR: C:/../external/gtest/BUILD.bazel:55:1: output 'external/gtest/gtest.if.lib' was not created
ERROR: C:/../external/gtest/BUILD.bazel:55:1: not all outputs were created or valid
Target //test:iterator_traits_test failed to build
The reason is a missing "win_def_file" attribute of the "gtest" and
"gtest_main" rules in the BUILD.bazel inside the google test library
package.
The "windows_export_all_symbols" feature is added to the rules, this
feature forces Bazel to export all symbols from the google test library
to linker. I believe exporting all symbols from a testing library makes
no problem for the application from a point of view on encapsulation.
Signed-off-by: Pavel Samolysov <samolisov@gmail.com>
Improve Bazel build files.
New target gtest_prod allows access to the FRIEND_TEST macro without depending on the entirety of GTest in production executables. Additionally, duplicate config_setting rules were removed and formatting was adjusted.
PiperOrigin-RevId: 220279205
This change adds the ability to generate stacktraces in Google Test on
both failures of assertions/expectations and on crashes. The
stacktrace support is conditionally available only when using Abseil
with Google Test.
To use this support, run the test under Bazel with a command like this:
bazel test --define absl=1 --test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1 //path/to/your:test
The "--define absl=1" part enables stacktraces on assertion/expectation
failures.
The "--test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" part enables
the signal handler that logs a stacktrace in the event of a crash
(this also requires the "--define absl=1" part). This is not the
default since it may interfere with existing tests.