Merge pull request #3291 from Be-ing:remove_zi_msvc
PiperOrigin-RevId: 363063211
diff --git a/.github/ISSUE_TEMPLATE/00-bug_report.md b/.github/ISSUE_TEMPLATE/00-bug_report.md
index 4d6a923..0f7e8b5 100644
--- a/.github/ISSUE_TEMPLATE/00-bug_report.md
+++ b/.github/ISSUE_TEMPLATE/00-bug_report.md
@@ -19,9 +19,11 @@
to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the
problem are also helpful.
-**What version of GoogleTest are you using?**
+**Does the bug persist in the most recent commit?**
-**What operating system and version are you using**
+We recommend using the latest commit in the master branch in your projects.
+
+**What operating system and version are you using?**
If you are using a Linux distribution please include the name and version of the
distribution as well.
diff --git a/README.md b/README.md
index 747d83e..8f6eea4 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,18 @@
### Announcements
+#### Live at Head
+
+GoogleTest now follows the
+[Abseil Live at Head philosophy](https://abseil.io/about/philosophy#upgrade-support).
+We recommend using the latest commit in the `master` branch in your projects.
+
+#### Documentation Updates
+
+Our documentation is now live on GitHub Pages at
+https://google.github.io/googletest/. We recommend browsing the documentation on
+GitHub Pages rather than directly in the repository.
+
#### Release 1.10.x
[Release 1.10.x](https://github.com/google/googletest/releases/tag/release-1.10.0)
@@ -13,10 +25,9 @@
#### Coming Soon
-* Post 1.10.x googletest will follow
- [Abseil Live at Head philosophy](https://abseil.io/about/philosophy)
-* We are also planning to take a dependency on
+* We are planning to take a dependency on
[Abseil](https://github.com/abseil/abseil-cpp).
+* More documentation improvements are planned.
## Welcome to **GoogleTest**, Google's C++ test framework!
@@ -26,14 +37,12 @@
### Getting Started
-The information for **GoogleTest** is available in the
-[GoogleTest Primer](docs/primer.md) documentation.
+See the [GoogleTest User's Guide](https://google.github.io/googletest/) for
+documentation. We recommend starting with the
+[GoogleTest Primer](https://google.github.io/googletest/primer.html).
-**GoogleMock** is an extension to GoogleTest for writing and using C++ mock
-classes. See the separate [GoogleMock documentation](googlemock/README.md).
-
-More detailed documentation for googletest is in its interior
-[googletest/README.md](googletest/README.md) file.
+More information about building GoogleTest can be found at
+[googletest/README.md](googletest/README.md).
## Features
@@ -128,7 +137,8 @@
## Contributing Changes
-Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) for details on how to
-contribute to this project.
+Please read
+[`CONTRIBUTING.md`](https://github.com/google/googletest/blob/master/CONTRIBUTING.md)
+for details on how to contribute to this project.
Happy testing!
diff --git a/WORKSPACE b/WORKSPACE
index 1f05d21..3b44517 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -4,27 +4,27 @@
http_archive(
name = "com_google_absl", # 2020-10-13T16:49:13Z
- urls = [
- "https://github.com/abseil/abseil-cpp/archive/f3f785ab59478dd0312bf1b5df65d380650bf0dc.zip"
- ],
- strip_prefix = "abseil-cpp-f3f785ab59478dd0312bf1b5df65d380650bf0dc",
sha256 = "00c3707bf9cd5eabd1ec6932cc65b97378c043f22573be3adf7d11bb7af17d06",
+ strip_prefix = "abseil-cpp-f3f785ab59478dd0312bf1b5df65d380650bf0dc",
+ urls = [
+ "https://github.com/abseil/abseil-cpp/archive/f3f785ab59478dd0312bf1b5df65d380650bf0dc.zip",
+ ],
)
http_archive(
name = "rules_cc", # 2020-10-05T06:01:24Z
- urls = [
- "https://github.com/bazelbuild/rules_cc/archive/f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9.zip"
- ],
- strip_prefix = "rules_cc-f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9",
sha256 = "35ea62c63cd71d4000efe85f9f4f17e8afb23896c37ee9510952db2e9d8fbb70",
+ strip_prefix = "rules_cc-f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9",
+ urls = [
+ "https://github.com/bazelbuild/rules_cc/archive/f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9.zip",
+ ],
)
http_archive(
name = "rules_python", # 2020-09-30T13:50:21Z
+ sha256 = "6e49996ad3cf45b2232b8f94ca1e3ead369c28394c51632be8d85fe826383012",
+ strip_prefix = "rules_python-c064f7008a30f307ea7516cf52358a653011f82b",
urls = [
"https://github.com/bazelbuild/rules_python/archive/c064f7008a30f307ea7516cf52358a653011f82b.zip",
],
- strip_prefix = "rules_python-c064f7008a30f307ea7516cf52358a653011f82b",
- sha256 = "6e49996ad3cf45b2232b8f94ca1e3ead369c28394c51632be8d85fe826383012",
)
diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh
new file mode 100644
index 0000000..5cbd7c4
--- /dev/null
+++ b/ci/linux-presubmit.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+#
+# Copyright 2020, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+set -euox pipefail
+
+readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20201008"
+readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20201015"
+
+SRC=$(realpath git/googletest)
+
+if [[ -z ${STD:-} ]]; then
+ STD="c++11 c++14 c++17 c++20"
+fi
+
+# Test the CMake build
+for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do
+ for cmake_off_on in OFF ON; do
+ time docker run \
+ --volume="${SRC}:/src:ro" \
+ --tmpfs="/build:exec" \
+ --workdir="/build" \
+ --rm \
+ --env="CC=${cc}" \
+ --env="CXX_FLAGS=\"-Werror -Wdeprecated\"" \
+ ${LINUX_LATEST_CONTAINER} \
+ /bin/bash -c "
+ cmake /src \
+ -DCMAKE_CXX_STANDARD=11 \
+ -Dgtest_build_samples=ON \
+ -Dgtest_build_tests=ON \
+ -Dgmock_build_tests=ON \
+ -Dcxx_no_exception=${cmake_off_on} \
+ -Dcxx_no_rtti=${cmake_off_on} && \
+ make -j$(nproc) && \
+ ctest -j$(nproc) --output-on-failure"
+ done
+done
+
+# Do one test with an older version of GCC
+time docker run \
+ --volume="${SRC}:/src:ro" \
+ --workdir="/src" \
+ --rm \
+ --env="CC=/usr/local/bin/gcc" \
+ ${LINUX_GCC_FLOOR_CONTAINER} \
+ /usr/local/bin/bazel test ... \
+ --copt="-Wall" \
+ --copt="-Werror" \
+ --copt="-Wno-error=pragmas" \
+ --keep_going \
+ --show_timestamps \
+ --test_output=errors
+
+# Test GCC
+for std in ${STD}; do
+ for absl in 0 1; do
+ time docker run \
+ --volume="${SRC}:/src:ro" \
+ --workdir="/src" \
+ --rm \
+ --env="CC=/usr/local/bin/gcc" \
+ --env="BAZEL_CXXOPTS=-std=${std}" \
+ ${LINUX_LATEST_CONTAINER} \
+ /usr/local/bin/bazel test ... \
+ --copt="-Wall" \
+ --copt="-Werror" \
+ --define="absl=${absl}" \
+ --keep_going \
+ --show_timestamps \
+ --test_output=errors
+ done
+done
+
+# Test Clang
+for std in ${STD}; do
+ for absl in 0 1; do
+ time docker run \
+ --volume="${SRC}:/src:ro" \
+ --workdir="/src" \
+ --rm \
+ --env="CC=/opt/llvm/clang/bin/clang" \
+ --env="BAZEL_CXXOPTS=-std=${std}" \
+ ${LINUX_LATEST_CONTAINER} \
+ /usr/local/bin/bazel test ... \
+ --copt="--gcc-toolchain=/usr/local" \
+ --copt="-Wall" \
+ --copt="-Werror" \
+ --define="absl=${absl}" \
+ --keep_going \
+ --linkopt="--gcc-toolchain=/usr/local" \
+ --show_timestamps \
+ --test_output=errors
+ done
+done
diff --git a/ci/macos-presubmit.sh b/ci/macos-presubmit.sh
new file mode 100644
index 0000000..4a5dc3e
--- /dev/null
+++ b/ci/macos-presubmit.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+# Copyright 2020, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+set -euox pipefail
+
+SRC=$(realpath git/googletest)
+
+# Test the CMake build
+for cmake_off_on in OFF ON; do
+ BUILD_DIR=$(mktemp -d build_dir.XXXXXXXX)
+ cd ${BUILD_DIR}
+ time cmake ${SRC} \
+ -DCMAKE_CXX_STANDARD=11 \
+ -Dgtest_build_samples=ON \
+ -Dgtest_build_tests=ON \
+ -Dgmock_build_tests=ON \
+ -Dcxx_no_exception=${cmake_off_on} \
+ -Dcxx_no_rtti=${cmake_off_on}
+ time make
+ time ctest -j$(nproc) --output-on-failure
+done
+
+# Test the Bazel build
+
+# If we are running on Kokoro, check for a versioned Bazel binary.
+KOKORO_GFILE_BAZEL_BIN="bazel-3.7.0-darwin-x86_64"
+if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then
+ BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}"
+ chmod +x ${BAZEL_BIN}
+else
+ BAZEL_BIN="bazel"
+fi
+
+cd ${SRC}
+for absl in 0 1; do
+ ${BAZEL_BIN} test ... \
+ --copt="-Wall" \
+ --copt="-Werror" \
+ --define="absl=${absl}" \
+ --keep_going \
+ --show_timestamps \
+ --test_output=errors
+done
diff --git a/docs/_data/navigation.yml b/docs/_data/navigation.yml
index 671ed90..b79f250 100644
--- a/docs/_data/navigation.yml
+++ b/docs/_data/navigation.yml
@@ -1,4 +1,8 @@
nav:
+- section: "Get Started"
+ items:
+ - title: "Supported Platforms"
+ url: "/platforms.html"
- section: "Guides"
items:
- title: "GoogleTest Primer"
diff --git a/docs/advanced.md b/docs/advanced.md
index 17ba194..4103507 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1501,11 +1501,11 @@
INSTANTIATE_TEST_SUITE_P(
MyGroup, MyTestSuite,
testing::Combine(
- testing::Values(MyType::VALUE_0, MyType::VALUE_1),
+ testing::Values(MyType::MY_FOO, MyType::MY_BAR),
testing::Values("A", "B")),
[](const testing::TestParamInfo<MyTestSuite::ParamType>& info) {
std::string name = absl::StrCat(
- std::get<0>(info.param) == MY_FOO ? "Foo" : "Bar",
+ std::get<0>(info.param) == MyType::MY_FOO ? "Foo" : "Bar",
std::get<1>(info.param));
absl::c_replace_if(name, [](char c) { return !std::isalnum(c); }, '');
return name;
diff --git a/docs/gmock_for_dummies.md b/docs/gmock_for_dummies.md
index 9b5bdcc..6e41caf 100644
--- a/docs/gmock_for_dummies.md
+++ b/docs/gmock_for_dummies.md
@@ -310,8 +310,8 @@
This syntax allows the test writer to specify "called with any arguments"
without explicitly specifying the number or types of arguments. To avoid
-unintended ambiguity, this syntax may only be used for methods which are not
-overloaded
+unintended ambiguity, this syntax may only be used for methods that are not
+overloaded.
Either form of the macro can be followed by some optional *clauses* that provide
more information about the expectation. We'll discuss how each clause works in
diff --git a/docs/index.md b/docs/index.md
index 9f18e3e..b162c74 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -5,17 +5,18 @@
GoogleTest is Google's C++ testing and mocking framework. This user's guide has
the following contents:
-* [GoogleTest Primer](primer) - Teaches you how to write simple tests using
+* [GoogleTest Primer](primer.md) - Teaches you how to write simple tests using
GoogleTest. Read this first if you are new to GoogleTest.
-* [GoogleTest Advanced](advanced) - Read this when you've finished the Primer
- and want to utilize GoogleTest to its full potential.
-* [GoogleTest Samples](samples) - Describes some GoogleTest samples.
-* [GoogleTest FAQ](faq) - Have a question? Want some tips? Check here first.
-* [Mocking for Dummies](gmock_for_dummies) - Teaches you how to create mock
+* [GoogleTest Advanced](advanced.md) - Read this when you've finished the
+ Primer and want to utilize GoogleTest to its full potential.
+* [GoogleTest Samples](samples.md) - Describes some GoogleTest samples.
+* [GoogleTest FAQ](faq.md) - Have a question? Want some tips? Check here
+ first.
+* [Mocking for Dummies](gmock_for_dummies.md) - Teaches you how to create mock
objects and use them in tests.
-* [Mocking Cookbook](gmock_cook_book) - Includes tips and approaches to common
- mocking use cases.
-* [Mocking Cheat Sheet](gmock_cheat_sheet) - A handy reference for matchers,
- actions, invariants, and more.
-* [Mocking FAQ](gmock_faq) - Contains answers to some mocking-specific
+* [Mocking Cookbook](gmock_cook_book.md) - Includes tips and approaches to
+ common mocking use cases.
+* [Mocking Cheat Sheet](gmock_cheat_sheet.md) - A handy reference for
+ matchers, actions, invariants, and more.
+* [Mocking FAQ](gmock_faq.md) - Contains answers to some mocking-specific
questions.
diff --git a/docs/platforms.md b/docs/platforms.md
new file mode 100644
index 0000000..eba6ef8
--- /dev/null
+++ b/docs/platforms.md
@@ -0,0 +1,35 @@
+# Supported Platforms
+
+GoogleTest requires a codebase and compiler compliant with the C++11 standard or
+newer.
+
+The GoogleTest code is officially supported on the following platforms.
+Operating systems or tools not listed below are community-supported. For
+community-supported platforms, patches that do not complicate the code may be
+considered.
+
+If you notice any problems on your platform, please file an issue on the
+[GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues).
+Pull requests containing fixes are welcome!
+
+### Operating systems
+
+* Linux
+* macOS
+* Windows
+
+### Compilers
+
+* gcc 5.0+
+* clang 5.0+
+* MSVC 2015+
+
+**macOS users:** Xcode 9.3+ provides clang 5.0+.
+
+### Build systems
+
+* [Bazel](https://bazel.build/)
+* [CMake](https://cmake.org/)
+
+Bazel is the build system used by the team internally and in tests. CMake is
+supported on a best-effort basis and by the community.
diff --git a/googlemock/README.md b/googlemock/README.md
index beeb7ea..ead6883 100644
--- a/googlemock/README.md
+++ b/googlemock/README.md
@@ -30,10 +30,10 @@
Details and examples can be found here:
-* [gMock for Dummies](../docs/gmock_for_dummies.md)
-* [Legacy gMock FAQ](../docs/gmock_faq.md)
-* [gMock Cookbook](../docs/gmock_cook_book.md)
-* [gMock Cheat Sheet](../docs/gmock_cheat_sheet.md)
+* [gMock for Dummies](https://google.github.io/googletest/gmock_for_dummies.html)
+* [Legacy gMock FAQ](https://google.github.io/googletest/gmock_faq.html)
+* [gMock Cookbook](https://google.github.io/googletest/gmock_cook_book.html)
+* [gMock Cheat Sheet](https://google.github.io/googletest/gmock_cheat_sheet.html)
Please note that code under scripts/generator/ is from the
[cppclean project](http://code.google.com/p/cppclean/) and under the Apache
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index 79eac15..f2393bd 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -127,8 +127,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#ifndef _WIN32_WCE
# include <errno.h>
@@ -1520,7 +1520,7 @@
// types instantiated. Up to 10 of the args that are provided by the
// args_type get passed, followed by a dummy of unspecified type for the
// remainder up to 10 explicit args.
- static const ExcessiveArg kExcessArg;
+ static constexpr ExcessiveArg kExcessArg{};
return static_cast<const Impl&>(*this).template gmock_PerformImpl<
/*function_type=*/function_type, /*return_type=*/R,
/*args_type=*/args_type,
@@ -1684,4 +1684,4 @@
# pragma warning(pop)
#endif
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
diff --git a/googlemock/include/gmock/gmock-cardinalities.h b/googlemock/include/gmock/gmock-cardinalities.h
index df81810..fc7f803 100644
--- a/googlemock/include/gmock/gmock-cardinalities.h
+++ b/googlemock/include/gmock/gmock-cardinalities.h
@@ -36,8 +36,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#include <limits.h>
#include <memory>
@@ -154,4 +154,4 @@
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h
index 29543f3..0fc6f6f 100644
--- a/googlemock/include/gmock/gmock-function-mocker.h
+++ b/googlemock/include/gmock/gmock-function-mocker.h
@@ -33,8 +33,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT
#include <type_traits> // IWYU pragma: keep
#include <utility> // IWYU pragma: keep
@@ -476,4 +476,4 @@
#define GMOCK_MOCKER_(arity, constness, Method) \
GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 5258878..eec5044 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -252,8 +252,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
#include <algorithm>
#include <cmath>
@@ -5389,4 +5389,4 @@
// declarations from this file.
#include "gmock/internal/custom/gmock-matchers.h"
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h
index 43275f4..fd29335 100644
--- a/googlemock/include/gmock/gmock-more-actions.h
+++ b/googlemock/include/gmock/gmock-more-actions.h
@@ -34,8 +34,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
#include <memory>
#include <utility>
@@ -570,4 +570,4 @@
} // namespace testing
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h
index 0265d5d..dfc77e3 100644
--- a/googlemock/include/gmock/gmock-more-matchers.h
+++ b/googlemock/include/gmock/gmock-more-matchers.h
@@ -37,8 +37,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
#include "gmock/gmock-matchers.h"
@@ -89,4 +89,4 @@
} // namespace testing
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
diff --git a/googlemock/include/gmock/gmock-nice-strict.h b/googlemock/include/gmock/gmock-nice-strict.h
index bf02092..9ee671f 100644
--- a/googlemock/include/gmock/gmock-nice-strict.h
+++ b/googlemock/include/gmock/gmock-nice-strict.h
@@ -60,8 +60,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
#include <type_traits>
@@ -260,4 +260,4 @@
} // namespace testing
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index 684c3c2..f1bd79c 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -58,8 +58,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#include <functional>
#include <map>
@@ -2033,4 +2033,4 @@
#define EXPECT_CALL(obj, call) \
GMOCK_ON_CALL_IMPL_(obj, InternalExpectedAt, call)
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h
index 20dba2a..12469bc 100644
--- a/googlemock/include/gmock/gmock.h
+++ b/googlemock/include/gmock/gmock.h
@@ -34,8 +34,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_
// This file implements the following syntax:
//
@@ -95,4 +95,4 @@
} // namespace testing
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_
diff --git a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h
index 003aed3..63f8999 100644
--- a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h
+++ b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h
@@ -1,6 +1,6 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
diff --git a/googlemock/include/gmock/internal/custom/gmock-matchers.h b/googlemock/include/gmock/internal/custom/gmock-matchers.h
index 66ac876..6384294 100644
--- a/googlemock/include/gmock/internal/custom/gmock-matchers.h
+++ b/googlemock/include/gmock/internal/custom/gmock-matchers.h
@@ -31,6 +31,6 @@
//
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
diff --git a/googlemock/include/gmock/internal/custom/gmock-port.h b/googlemock/include/gmock/internal/custom/gmock-port.h
index bb91e24..1437869 100644
--- a/googlemock/include/gmock/internal/custom/gmock-port.h
+++ b/googlemock/include/gmock/internal/custom/gmock-port.h
@@ -33,7 +33,7 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index 8454317..317544a 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -36,8 +36,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#include <stdio.h>
#include <ostream> // NOLINT
@@ -456,4 +456,4 @@
} // namespace internal
} // namespace testing
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
diff --git a/googlemock/include/gmock/internal/gmock-port.h b/googlemock/include/gmock/internal/gmock-port.h
index 3f283c8..367a44d 100644
--- a/googlemock/include/gmock/internal/gmock-port.h
+++ b/googlemock/include/gmock/internal/gmock-port.h
@@ -37,8 +37,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
#include <assert.h>
#include <stdlib.h>
@@ -84,4 +84,4 @@
#endif // !defined(GMOCK_DECLARE_bool_)
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
diff --git a/googlemock/include/gmock/internal/gmock-pp.h b/googlemock/include/gmock/internal/gmock-pp.h
index 924dde8..94d61c0 100644
--- a/googlemock/include/gmock/internal/gmock-pp.h
+++ b/googlemock/include/gmock/internal/gmock-pp.h
@@ -1,5 +1,5 @@
-#ifndef GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
-#define GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
+#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
+#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
// Expands and concatenates the arguments. Constructed macros reevaluate.
#define GMOCK_PP_CAT(_1, _2) GMOCK_PP_INTERNAL_CAT(_1, _2)
@@ -276,4 +276,4 @@
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
-#endif // GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
+#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
diff --git a/googlemock/test/BUILD.bazel b/googlemock/test/BUILD.bazel
index ee75f27..1f7bd06 100644
--- a/googlemock/test/BUILD.bazel
+++ b/googlemock/test/BUILD.bazel
@@ -54,7 +54,7 @@
srcs = ["gmock_test_utils.py"],
deps = [
"//googletest/test:gtest_test_utils",
- ]
+ ],
)
cc_binary(
@@ -104,11 +104,11 @@
":gmock_output_test_golden.txt",
],
python_version = "PY2",
- deps = [":gmock_test_utils"],
tags = [
"no_test_msvc2015",
"no_test_msvc2017",
],
+ deps = [":gmock_test_utils"],
)
cc_test(
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index cd09494..a7e0a3c 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -113,6 +113,11 @@
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-port.h"
+#if GTEST_HAS_RTTI
+#include <typeindex>
+#include <typeinfo>
+#endif // GTEST_HAS_RTTI
+
namespace testing {
// Definitions in the internal* namespaces are subject to change without notice.
@@ -650,6 +655,18 @@
*os << ')';
}
+#if GTEST_HAS_RTTI
+inline void PrintTo(const ::std::type_info& value, ::std::ostream* os) {
+ internal::PrintTo<::std::type_info>(value, os);
+ *os << " (\"" << value.name() << "\")";
+}
+
+inline void PrintTo(const ::std::type_index& value, ::std::ostream* os) {
+ internal::PrintTo<::std::type_index>(value, os);
+ *os << " (\"" << value.name() << "\")";
+}
+#endif // GTEST_HAS_RTTI
+
// Implements printing a non-reference type T by letting the compiler
// pick the right overload of PrintTo() for T.
template <typename T>
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 632ef2b..ff557d5 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -895,16 +895,16 @@
class HasDebugStringAndShortDebugString {
private:
template <typename C>
- static constexpr auto CheckDebugString(C*) -> typename std::is_same<
+ static auto CheckDebugString(C*) -> typename std::is_same<
std::string, decltype(std::declval<const C>().DebugString())>::type;
template <typename>
- static constexpr std::false_type CheckDebugString(...);
+ static std::false_type CheckDebugString(...);
template <typename C>
- static constexpr auto CheckShortDebugString(C*) -> typename std::is_same<
+ static auto CheckShortDebugString(C*) -> typename std::is_same<
std::string, decltype(std::declval<const C>().ShortDebugString())>::type;
template <typename>
- static constexpr std::false_type CheckShortDebugString(...);
+ static std::false_type CheckShortDebugString(...);
using HasDebugStringType = decltype(CheckDebugString<T>(nullptr));
using HasShortDebugStringType = decltype(CheckShortDebugString<T>(nullptr));
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index ecc47d1..c3d6dfc 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -248,7 +248,7 @@
msg << "detected " << thread_count << " threads.";
}
msg << " See "
- "https://github.com/google/googletest/blob/master/googletest/docs/"
+ "https://github.com/google/googletest/blob/master/docs/"
"advanced.md#death-tests-and-threads"
<< " for more explanation and suggested solutions, especially if"
<< " this is the last message you see before your test times out.";
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d659e7d..9089f50 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -1031,7 +1031,25 @@
); // NOLINT
}
-// Returns the current time in milliseconds.
+// A helper class for measuring elapsed times.
+class Timer {
+ public:
+ Timer() : start_(std::chrono::steady_clock::now()) {}
+
+ // Return time elapsed in milliseconds since the timer was created.
+ TimeInMillis Elapsed() {
+ return std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - start_)
+ .count();
+ }
+
+ private:
+ std::chrono::time_point<std::chrono::steady_clock> start_;
+};
+
+// Returns a timestamp as milliseconds since the epoch. Note this time may jump
+// around subject to adjustments by the system, to measure elapsed time use
+// Timer instead.
TimeInMillis GetTimeInMillis() {
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() -
@@ -2824,7 +2842,8 @@
// Notifies the unit test event listeners that a test is about to start.
repeater->OnTestStart(*this);
- const TimeInMillis start = internal::GetTimeInMillis();
+ result_.set_start_timestamp(internal::GetTimeInMillis());
+ internal::Timer timer;
impl->os_stack_trace_getter()->UponLeavingGTest();
@@ -2849,8 +2868,7 @@
test, &Test::DeleteSelf_, "the test fixture's destructor");
}
- result_.set_start_timestamp(start);
- result_.set_elapsed_time(internal::GetTimeInMillis() - start);
+ result_.set_elapsed_time(timer.Elapsed());
// Notifies the unit test event listener that a test has just finished.
repeater->OnTestEnd(*this);
@@ -2992,6 +3010,7 @@
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
start_timestamp_ = internal::GetTimeInMillis();
+ internal::Timer timer;
for (int i = 0; i < total_test_count(); i++) {
GetMutableTestInfo(i)->Run();
if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
@@ -3001,7 +3020,7 @@
break;
}
}
- elapsed_time_ = internal::GetTimeInMillis() - start_timestamp_;
+ elapsed_time_ = timer.Elapsed();
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
@@ -3909,6 +3928,16 @@
// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
+ // Streams a test suite XML stanza containing the given test result.
+ //
+ // Requires: result.Failed()
+ static void OutputXmlTestSuiteForTestResult(::std::ostream* stream,
+ const TestResult& result);
+
+ // Streams an XML representation of a TestResult object.
+ static void OutputXmlTestResult(::std::ostream* stream,
+ const TestResult& result);
+
// Streams an XML representation of a TestInfo object.
static void OutputXmlTestInfo(::std::ostream* stream,
const char* test_suite_name,
@@ -4124,6 +4153,43 @@
*stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\"";
}
+// Streams a test suite XML stanza containing the given test result.
+void XmlUnitTestResultPrinter::OutputXmlTestSuiteForTestResult(
+ ::std::ostream* stream, const TestResult& result) {
+ // Output the boilerplate for a minimal test suite with one test.
+ *stream << " <testsuite";
+ OutputXmlAttribute(stream, "testsuite", "name", "NonTestSuiteFailure");
+ OutputXmlAttribute(stream, "testsuite", "tests", "1");
+ OutputXmlAttribute(stream, "testsuite", "failures", "1");
+ OutputXmlAttribute(stream, "testsuite", "disabled", "0");
+ OutputXmlAttribute(stream, "testsuite", "skipped", "0");
+ OutputXmlAttribute(stream, "testsuite", "errors", "0");
+ OutputXmlAttribute(stream, "testsuite", "time",
+ FormatTimeInMillisAsSeconds(result.elapsed_time()));
+ OutputXmlAttribute(
+ stream, "testsuite", "timestamp",
+ FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
+ *stream << ">";
+
+ // Output the boilerplate for a minimal test case with a single test.
+ *stream << " <testcase";
+ OutputXmlAttribute(stream, "testcase", "name", "");
+ OutputXmlAttribute(stream, "testcase", "status", "run");
+ OutputXmlAttribute(stream, "testcase", "result", "completed");
+ OutputXmlAttribute(stream, "testcase", "classname", "");
+ OutputXmlAttribute(stream, "testcase", "time",
+ FormatTimeInMillisAsSeconds(result.elapsed_time()));
+ OutputXmlAttribute(
+ stream, "testcase", "timestamp",
+ FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
+
+ // Output the actual test result.
+ OutputXmlTestResult(stream, result);
+
+ // Complete the test suite.
+ *stream << " </testsuite>\n";
+}
+
// Prints an XML representation of a TestInfo object.
void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
const char* test_suite_name,
@@ -4167,6 +4233,11 @@
FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
OutputXmlAttribute(stream, kTestsuite, "classname", test_suite_name);
+ OutputXmlTestResult(stream, result);
+}
+
+void XmlUnitTestResultPrinter::OutputXmlTestResult(::std::ostream* stream,
+ const TestResult& result) {
int failures = 0;
int skips = 0;
for (int i = 0; i < result.total_part_count(); ++i) {
@@ -4281,6 +4352,13 @@
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));
}
+
+ // If there was a test failure outside of one of the test suites (like in a
+ // test environment) include that in the output.
+ if (unit_test.ad_hoc_test_result().Failed()) {
+ OutputXmlTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
+ }
+
*stream << "</" << kTestsuites << ">\n";
}
@@ -4371,6 +4449,16 @@
const std::string& indent,
bool comma = true);
+ // Streams a test suite JSON stanza containing the given test result.
+ //
+ // Requires: result.Failed()
+ static void OutputJsonTestSuiteForTestResult(::std::ostream* stream,
+ const TestResult& result);
+
+ // Streams a JSON representation of a TestResult object.
+ static void OutputJsonTestResult(::std::ostream* stream,
+ const TestResult& result);
+
// Streams a JSON representation of a TestInfo object.
static void OutputJsonTestInfo(::std::ostream* stream,
const char* test_suite_name,
@@ -4521,6 +4609,48 @@
*stream << ",\n";
}
+// Streams a test suite JSON stanza containing the given test result.
+void JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult(
+ ::std::ostream* stream, const TestResult& result) {
+ // Output the boilerplate for a new test suite.
+ *stream << Indent(4) << "{\n";
+ OutputJsonKey(stream, "testsuite", "name", "NonTestSuiteFailure", Indent(6));
+ OutputJsonKey(stream, "testsuite", "tests", 1, Indent(6));
+ if (!GTEST_FLAG(list_tests)) {
+ OutputJsonKey(stream, "testsuite", "failures", 1, Indent(6));
+ OutputJsonKey(stream, "testsuite", "disabled", 0, Indent(6));
+ OutputJsonKey(stream, "testsuite", "skipped", 0, Indent(6));
+ OutputJsonKey(stream, "testsuite", "errors", 0, Indent(6));
+ OutputJsonKey(stream, "testsuite", "time",
+ FormatTimeInMillisAsDuration(result.elapsed_time()),
+ Indent(6));
+ OutputJsonKey(stream, "testsuite", "timestamp",
+ FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
+ Indent(6));
+ }
+ *stream << Indent(6) << "\"testsuite\": [\n";
+
+ // Output the boilerplate for a new test case.
+ *stream << Indent(8) << "{\n";
+ OutputJsonKey(stream, "testcase", "name", "", Indent(10));
+ OutputJsonKey(stream, "testcase", "status", "RUN", Indent(10));
+ OutputJsonKey(stream, "testcase", "result", "COMPLETED", Indent(10));
+ OutputJsonKey(stream, "testcase", "timestamp",
+ FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
+ Indent(10));
+ OutputJsonKey(stream, "testcase", "time",
+ FormatTimeInMillisAsDuration(result.elapsed_time()),
+ Indent(10));
+ OutputJsonKey(stream, "testcase", "classname", "", Indent(10), false);
+ *stream << TestPropertiesAsJson(result, Indent(10));
+
+ // Output the actual test result.
+ OutputJsonTestResult(stream, result);
+
+ // Finish the test suite.
+ *stream << "\n" << Indent(6) << "]\n" << Indent(4) << "}";
+}
+
// Prints a JSON representation of a TestInfo object.
void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,
const char* test_suite_name,
@@ -4563,6 +4693,13 @@
false);
*stream << TestPropertiesAsJson(result, kIndent);
+ OutputJsonTestResult(stream, result);
+}
+
+void JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,
+ const TestResult& result) {
+ const std::string kIndent = Indent(10);
+
int failures = 0;
for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
@@ -4673,6 +4810,12 @@
}
}
+ // If there was a test failure outside of one of the test suites (like in a
+ // test environment) include that in the output.
+ if (unit_test.ad_hoc_test_result().Failed()) {
+ OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
+ }
+
*stream << "\n" << kIndent << "]\n" << "}\n";
}
@@ -5665,7 +5808,7 @@
// assertions executed before RUN_ALL_TESTS().
ClearNonAdHocTestResult();
- const TimeInMillis start = GetTimeInMillis();
+ Timer timer;
// Shuffles test suites and tests if requested.
if (has_tests_to_run && GTEST_FLAG(shuffle)) {
@@ -5731,7 +5874,7 @@
repeater->OnEnvironmentsTearDownEnd(*parent_);
}
- elapsed_time_ = GetTimeInMillis() - start;
+ elapsed_time_ = timer.Elapsed();
// Tells the unit test event listener that the tests have just finished.
repeater->OnTestIterationEnd(*parent_, i);
diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py
index e799d47..41c8565 100644
--- a/googletest/test/googletest-json-output-unittest.py
+++ b/googletest/test/googletest-json-output-unittest.py
@@ -612,15 +612,59 @@
}],
}
-EXPECTED_EMPTY = {
- u'tests': 0,
- u'failures': 0,
- u'disabled': 0,
- u'errors': 0,
- u'time': u'*',
- u'timestamp': u'*',
- u'name': u'AllTests',
- u'testsuites': [],
+EXPECTED_NO_TEST = {
+ u'tests':
+ 0,
+ u'failures':
+ 0,
+ u'disabled':
+ 0,
+ u'errors':
+ 0,
+ u'time':
+ u'*',
+ u'timestamp':
+ u'*',
+ u'name':
+ u'AllTests',
+ u'testsuites': [{
+ u'name':
+ u'NonTestSuiteFailure',
+ u'tests':
+ 1,
+ u'failures':
+ 1,
+ u'disabled':
+ 0,
+ u'skipped':
+ 0,
+ u'errors':
+ 0,
+ u'time':
+ u'*',
+ u'timestamp':
+ u'*',
+ u'testsuite': [{
+ u'name':
+ u'',
+ u'status':
+ u'RUN',
+ u'result':
+ u'COMPLETED',
+ u'time':
+ u'*',
+ u'timestamp':
+ u'*',
+ u'classname':
+ u'',
+ u'failures': [{
+ u'failure': u'gtest_no_test_unittest.cc:*\n'
+ u'Expected equality of these values:\n'
+ u' 1\n 2' + STACK_TRACE_TEMPLATE,
+ u'type': u'',
+ }]
+ }]
+ }],
}
GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)
@@ -645,14 +689,14 @@
"""
self._TestJsonOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY, 1)
- def testEmptyJsonOutput(self):
+ def testNoTestJsonOutput(self):
"""Verifies JSON output for a Google Test binary without actual tests.
- Runs a test program that generates an empty JSON output, and
- tests that the JSON output is expected.
+ Runs a test program that generates an JSON output for a binary with no
+ tests, and tests that the JSON output is expected.
"""
- self._TestJsonOutput('gtest_no_test_unittest', EXPECTED_EMPTY, 0)
+ self._TestJsonOutput('gtest_no_test_unittest', EXPECTED_NO_TEST, 0)
def testTimestampValue(self):
"""Checks whether the timestamp attribute in the JSON output is valid.
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index 8247d4e..f037480 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -1589,6 +1589,61 @@
"\n As Text: \"From ä — αΊ‘\"");
}
+#if GTEST_HAS_RTTI
+template <typename T>
+class PrintToStringTest : public testing::Test {
+ public:
+ using TestType = T;
+};
+
+struct PrintBase {
+ virtual ~PrintBase() = default;
+};
+struct PrintDerived : PrintBase {};
+
+using PrintToStringTestTypes =
+ testing::Types<void, int, const volatile int*, PrintBase, PrintDerived>;
+TYPED_TEST_SUITE(PrintToStringTest, PrintToStringTestTypes);
+
+// Returns `true` if `haystack` contains `needle`.
+//
+// FIXME: Replace with `EXPECT_THAT(haystack, HasSubstr(needle))` once
+// GoogleTest starts depending on GoogleMock.
+bool ContainsSubstr(const std::string& haystack, const std::string& needle) {
+ return haystack.find(needle) != std::string::npos;
+}
+
+TYPED_TEST(PrintToStringTest, IncludesNameWithTypeInfoAndTypeIndex) {
+ const ::std::type_info& info = typeid(typename TestFixture::TestType);
+ SCOPED_TRACE(info.name());
+ EXPECT_TRUE(ContainsSubstr(PrintToString(info), info.name()));
+ EXPECT_TRUE(
+ ContainsSubstr(PrintToString(::std::type_index{info}), info.name()));
+}
+
+TEST(PrintToStringTest, IncludesNameWithTypeInfoAndTypeIndexViaBaseRef) {
+ PrintDerived derived;
+ PrintBase& base = derived;
+
+ {
+ const ::std::type_info& derived_info = typeid(derived);
+ SCOPED_TRACE(derived_info.name());
+ EXPECT_TRUE(
+ ContainsSubstr(PrintToString(derived_info), derived_info.name()));
+ EXPECT_TRUE(ContainsSubstr(PrintToString(::std::type_index{derived_info}),
+ derived_info.name()));
+ }
+ {
+ const ::std::type_info& base_ref_info = typeid(base);
+ SCOPED_TRACE(base_ref_info.name());
+ EXPECT_TRUE(
+ ContainsSubstr(PrintToString(base_ref_info), base_ref_info.name()));
+ EXPECT_TRUE(ContainsSubstr(PrintToString(::std::type_index{base_ref_info}),
+ base_ref_info.name()));
+ }
+}
+#endif // GTEST_HAS_RTTI
+
TEST(IsValidUTF8Test, IllFormedUTF8) {
// The following test strings are ill-formed UTF-8 and are printed
// as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index de8b8c7..eade7aa 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -216,10 +216,20 @@
</testsuite>
</testsuites>"""
-EXPECTED_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
+EXPECTED_NO_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="0" failures="0" disabled="0" errors="0" time="*"
timestamp="*" name="AllTests">
-</testsuites>"""
+ <testsuite name="NonTestSuiteFailure" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
+ <testcase name="" status="run" result="completed" time="*" timestamp="*" classname="">
+ <failure message="gtest_no_test_unittest.cc:*
Expected equality of these values:
 1
 2" type=""><![CDATA[gtest_no_test_unittest.cc:*
+Expected equality of these values:
+ 1
+ 2%(stack)s]]></failure>
+ </testcase>
+ </testsuite>
+</testsuites>""" % {
+ 'stack': STACK_TRACE_TEMPLATE
+}
GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)
@@ -242,14 +252,14 @@
"""
self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY_XML, 1)
- def testEmptyXmlOutput(self):
+ def testNoTestXmlOutput(self):
"""Verifies XML output for a Google Test binary without actual tests.
- Runs a test program that generates an empty XML output, and
- tests that the XML output is expected.
+ Runs a test program that generates an XML output for a binary without tests,
+ and tests that the XML output is expected.
"""
- self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)
+ self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_NO_TEST_XML, 0)
def testTimestampValue(self):
"""Checks whether the timestamp attribute in the XML output is valid.