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.
Because in `std::tr1::tuple_element` the first template parameter should be of type int (https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/a00547.html), but the code inserts a size_t, the first template parameter should be casted to int before, to get rid of the following errors:
googletest-src/googletest/include/gtest/gtest-printers.h:957:60: error: conversion from ‘long unsigned int’ to ‘int’ may change value [-Werror=conversion]
struct tuple_element : ::std::tr1::tuple_element<I, Tuple> {};
and
googletest-src/googletest/include/gtest/gtest-printers.h:961:56: error: conversion from ‘long unsigned int’ to ‘int’ may change value [-Werror=conversion]
const typename ::std::tr1::tuple_element<I, Tuple>::type>::type get(
non-ASCII charactors are interpreted as Shift-JIS on the environment.
But the charators in the files are non Shift-JIS charactors and the compiler
stops compiling with C4819.
To fix the errors, remove non-ASCII charactors.
GTEST_TEST_FILTER_ENV_VAR_ was used to specify an environment variable to obtain
the default test filter from. By default it was unset which broke
"--test_filter" for bazel. This CL eliminates GTEST_TEST_FILTER_ENV_VAR_ and
explicitly obtains the default test filter from the environment variable
TESTBRIDGE_TEST_ONLY if it exists.
When we do parallel test execution with a process for a test,
initialization of gtest become performance bottleneck when the test
binary contains many testcases.
Especially, some parameterlized test in chromium browser affected by
largely when address sanitizer is enabled.
Address sanitizer does not allow using optimized strcmp function and
test addition in parameterized test require lookup of test case using
strcmp.
This patch reduces the number of strcmp, it is called when registering
parameterized test. Using reverse iterator improves the time to find
registered tests in such case.
Some tests for chromium browser using address sanitizer finished 2x
faster with this patch.