summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WORKSPACE16
-rw-r--r--ci/linux-presubmit.sh122
-rw-r--r--ci/macos-presubmit.sh71
-rw-r--r--docs/_data/navigation.yml4
-rw-r--r--docs/advanced.md4
-rw-r--r--docs/index.md23
-rw-r--r--docs/platforms.md35
-rw-r--r--googlemock/test/BUILD.bazel4
-rw-r--r--googletest/include/gtest/gtest-printers.h14
-rw-r--r--googletest/src/gtest-death-test.cc2
-rw-r--r--googletest/test/googletest-printers-test.cc71
11 files changed, 307 insertions, 59 deletions
diff --git a/WORKSPACE b/WORKSPACE
index 1f05d21a..3b445173 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -4,27 +4,27 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_absl", # 2020-10-13T16:49:13Z
+ sha256 = "00c3707bf9cd5eabd1ec6932cc65b97378c043f22573be3adf7d11bb7af17d06",
+ strip_prefix = "abseil-cpp-f3f785ab59478dd0312bf1b5df65d380650bf0dc",
urls = [
- "https://github.com/abseil/abseil-cpp/archive/f3f785ab59478dd0312bf1b5df65d380650bf0dc.zip"
+ "https://github.com/abseil/abseil-cpp/archive/f3f785ab59478dd0312bf1b5df65d380650bf0dc.zip",
],
- strip_prefix = "abseil-cpp-f3f785ab59478dd0312bf1b5df65d380650bf0dc",
- sha256 = "00c3707bf9cd5eabd1ec6932cc65b97378c043f22573be3adf7d11bb7af17d06",
)
http_archive(
name = "rules_cc", # 2020-10-05T06:01:24Z
+ sha256 = "35ea62c63cd71d4000efe85f9f4f17e8afb23896c37ee9510952db2e9d8fbb70",
+ strip_prefix = "rules_cc-f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9",
urls = [
- "https://github.com/bazelbuild/rules_cc/archive/f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9.zip"
+ "https://github.com/bazelbuild/rules_cc/archive/f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9.zip",
],
- strip_prefix = "rules_cc-f055da4ff0cb2b3c73de1fe2f094ebdfb8b3acb9",
- sha256 = "35ea62c63cd71d4000efe85f9f4f17e8afb23896c37ee9510952db2e9d8fbb70",
)
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 00000000..5cbd7c41
--- /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 00000000..4a5dc3e9
--- /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 671ed905..b79f2505 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 17ba194d..4103507b 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1501,11 +1501,11 @@ class MyTestSuite : public testing::TestWithParam<std::tuple<MyType, std::string
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/index.md b/docs/index.md
index 9f18e3e8..b162c740 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 00000000..eba6ef80
--- /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/test/BUILD.bazel b/googlemock/test/BUILD.bazel
index ee75f27f..1f7bd067 100644
--- a/googlemock/test/BUILD.bazel
+++ b/googlemock/test/BUILD.bazel
@@ -54,7 +54,7 @@ py_library(
srcs = ["gmock_test_utils.py"],
deps = [
"//googletest/test:gtest_test_utils",
- ]
+ ],
)
cc_binary(
@@ -104,11 +104,11 @@ py_test(
":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 aa9ca48c..a7e0a3c9 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -655,22 +655,16 @@ void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
*os << ')';
}
-template <typename T>
-void PrintWithNameTo(const T& value, ::std::ostream* os) {
- internal::PrintTo<T>(value, os);
- *os << " (\"" << value.name() << "\")";
-}
-
#if GTEST_HAS_RTTI
-
inline void PrintTo(const ::std::type_info& value, ::std::ostream* os) {
- internal::PrintWithNameTo(value, os);
+ internal::PrintTo<::std::type_info>(value, os);
+ *os << " (\"" << value.name() << "\")";
}
inline void PrintTo(const ::std::type_index& value, ::std::ostream* os) {
- internal::PrintWithNameTo(value, 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
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index ecc47d1b..c3d6dfcc 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -248,7 +248,7 @@ static std::string DeathTestThreadWarning(size_t thread_count) {
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/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index 1d35c549..f037480b 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -1590,36 +1590,57 @@ TEST(PrintToStringTest, WorksForCharArrayWithEmbeddedNul) {
}
#if GTEST_HAS_RTTI
-TEST(PrintToStringTest, IncludesNameWithTypeInfoAndTypeIndex) {
- // The following lambda tests that both the printed string for the specified
- // `typeid`, and the one for its `std::type_index` contain the string returned
- // by its `name()` member function.
- const auto TestTypeId = [](const ::std::type_info& id) {
- const auto name = id.name();
- const auto contains_name = [name](const ::std::string& str) {
- return str.find(name) != ::std::string::npos;
- };
- EXPECT_TRUE(contains_name(PrintToString(id)));
- EXPECT_TRUE(contains_name(PrintToString(::std::type_index{id})));
- };
+template <typename T>
+class PrintToStringTest : public testing::Test {
+ public:
+ using TestType = T;
+};
- TestTypeId(typeid(void));
- TestTypeId(typeid(int));
- TestTypeId(typeid(const volatile int*));
+struct PrintBase {
+ virtual ~PrintBase() = default;
+};
+struct PrintDerived : PrintBase {};
- struct Base {
- virtual ~Base() = default;
- };
- struct Derived : Base {};
+using PrintToStringTestTypes =
+ testing::Types<void, int, const volatile int*, PrintBase, PrintDerived>;
+TYPED_TEST_SUITE(PrintToStringTest, PrintToStringTestTypes);
- TestTypeId(typeid(Base));
- TestTypeId(typeid(Derived));
+// 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()));
+}
- Derived derived;
- Base& base = derived;
+TEST(PrintToStringTest, IncludesNameWithTypeInfoAndTypeIndexViaBaseRef) {
+ PrintDerived derived;
+ PrintBase& base = derived;
- TestTypeId(typeid(base));
- TestTypeId(typeid(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
OpenPOWER on IntegriCloud