Commit a8ce8d27 authored by xiabo's avatar xiabo
Browse files

修改googletest版本

parent 0a21fff9
name: Bug Report
description: Let us know that something does not work as expected.
title: "[Bug]: Please title this bug report"
body:
- type: textarea
id: what-happened
attributes:
label: Describe the issue
description: What happened, and what did you expect to happen?
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce the problem
description: It is important that we are able to reproduce the problem that you are experiencing. Please provide all code and relevant steps to reproduce the problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the problem are also helpful.
validations:
required: true
- type: textarea
id: version
attributes:
label: What version of GoogleTest are you using?
description: Please include the output of `git rev-parse HEAD` or the GoogleTest release version number that you are using.
validations:
required: true
- type: textarea
id: os
attributes:
label: What operating system and version are you using?
description: If you are using a Linux distribution please include the name and version of the distribution as well.
validations:
required: true
- type: textarea
id: compiler
attributes:
label: What compiler and version are you using?
description: Please include the output of `gcc -v` or `clang -v`, or the equivalent for your compiler.
validations:
required: true
- type: textarea
id: buildsystem
attributes:
label: What build system are you using?
description: Please include the output of `bazel --version` or `cmake --version`, or the equivalent for your build system.
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional context
description: Add any other context about the problem here.
validations:
required: false
name: Feature request
description: Propose a new feature.
title: "[FR]: Please title this feature request"
labels: "enhancement"
body:
- type: textarea
id: version
attributes:
label: Does the feature exist in the most recent commit?
description: We recommend using the latest commit from GitHub in your projects.
validations:
required: true
- type: textarea
id: why
attributes:
label: Why do we need this feature?
description: Ideally, explain why a combination of existing features cannot be used instead.
validations:
required: true
- type: textarea
id: proposal
attributes:
label: Describe the proposal.
description: Include a detailed description of the feature, with usage examples.
validations:
required: true
- type: textarea
id: platform
attributes:
label: Is the feature specific to an operating system, compiler, or build system version?
description: If it is, please specify which versions.
validations:
required: true
blank_issues_enabled: false
contact_links:
- name: Get Help
url: https://github.com/google/googletest/discussions
about: Please ask and answer questions here.
workspace(name = "com_google_googletest")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_absl", # 2023-01-10T21:08:25Z
sha256 = "f9a4e749f42c386a32a90fddf0e2913ed408d10c42f7f33ccf4c59ac4f0d1d05",
strip_prefix = "abseil-cpp-52835439ca90d86b27bf8cd1708296e95604d724",
urls = ["https://github.com/abseil/abseil-cpp/archive/52835439ca90d86b27bf8cd1708296e95604d724.zip"],
)
# Note this must use a commit from the `abseil` branch of the RE2 project.
# https://github.com/google/re2/tree/abseil
http_archive(
name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z
sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5",
strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e",
urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"],
)
http_archive(
name = "rules_python", # 2023-01-10T22:00:51Z
sha256 = "5de54486a60ad8948dabe49605bb1c08053e04001a431ab3e96745b4d97a4419",
strip_prefix = "rules_python-70cce26432187a60b4e950118791385e6fb3c26f",
urls = ["https://github.com/bazelbuild/rules_python/archive/70cce26432187a60b4e950118791385e6fb3c26f.zip"],
)
http_archive(
name = "bazel_skylib", # 2022-11-16T18:29:32Z
sha256 = "a22290c26d29d3ecca286466f7f295ac6cbe32c0a9da3a91176a90e0725e3649",
strip_prefix = "bazel-skylib-5bfcb1a684550626ce138fe0fe8f5f702b3764c3",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/5bfcb1a684550626ce138fe0fe8f5f702b3764c3.zip"],
)
http_archive(
name = "platforms", # 2022-11-09T19:18:22Z
sha256 = "b4a3b45dc4202e2b3e34e3bc49d2b5b37295fc23ea58d88fb9e01f3642ad9b55",
strip_prefix = "platforms-3fbc687756043fb58a407c2ea8c944bc2fe1d922",
urls = ["https://github.com/bazelbuild/platforms/archive/3fbc687756043fb58a407c2ea8c944bc2fe1d922.zip"],
)
SETLOCAL ENABLEDELAYEDEXPANSION
SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-windows-x86_64.exe
SET PATH=C:\Python37;%PATH%
SET BAZEL_PYTHON=C:\python37\python.exe
SET BAZEL_SH=C:\tools\msys64\usr\bin\bash.exe
SET CMAKE_BIN="C:\Program Files\CMake\bin\cmake.exe"
SET CTEST_BIN="C:\Program Files\CMake\bin\ctest.exe"
SET CTEST_OUTPUT_ON_FAILURE=1
IF EXIST git\googletest (
CD git\googletest
) ELSE IF EXIST github\googletest (
CD github\googletest
)
IF %errorlevel% neq 0 EXIT /B 1
:: ----------------------------------------------------------------------------
:: CMake Visual Studio 15 2017 Win64
MKDIR cmake_msvc2017
CD cmake_msvc2017
%CMAKE_BIN% .. ^
-G "Visual Studio 15 2017 Win64" ^
-DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^
-DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^
-DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^
-Dgtest_build_samples=ON ^
-Dgtest_build_tests=ON ^
-Dgmock_build_tests=ON
IF %errorlevel% neq 0 EXIT /B 1
%CMAKE_BIN% --build . --target ALL_BUILD --config Debug -- -maxcpucount
IF %errorlevel% neq 0 EXIT /B 1
%CTEST_BIN% -C Debug --timeout 600
IF %errorlevel% neq 0 EXIT /B 1
CD ..
RMDIR /S /Q cmake_msvc2017
:: ----------------------------------------------------------------------------
:: Bazel Visual Studio 15 2017 Win64
SET BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC
%BAZEL_EXE% test ... ^
--compilation_mode=dbg ^
--copt=/std:c++14 ^
--copt=/WX ^
--features=external_include_paths ^
--keep_going ^
--test_output=errors ^
--test_tag_filters=-no_test_msvc2017
IF %errorlevel% neq 0 EXIT /B 1
#include <sys/stat.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h"
namespace {
class SetEnv {
public:
// Sets the environment value with name `name` to `value`, unless `value` is
// nullptr, in which case it unsets it. Restores the original value on
// destruction.
SetEnv(const char* name, const char* value) : name_(name) {
const char* old_value = getenv(name);
if (old_value != nullptr) {
saved_value_ = old_value;
have_saved_value_ = true;
}
if (value == nullptr) {
GTEST_CHECK_POSIX_SUCCESS_(unsetenv(name));
} else {
GTEST_CHECK_POSIX_SUCCESS_(setenv(name, value, 1 /*overwrite*/));
}
}
~SetEnv() {
if (have_saved_value_) {
GTEST_CHECK_POSIX_SUCCESS_(
setenv(name_.c_str(), saved_value_.c_str(), 1 /*overwrite*/));
} else {
GTEST_CHECK_POSIX_SUCCESS_(unsetenv(name_.c_str()));
}
}
private:
std::string name_;
bool have_saved_value_ = false;
std::string saved_value_;
};
class MakeTempDir {
public:
// Creates a directory with a unique name including `testname`.
// The destructor removes it.
explicit MakeTempDir(const std::string& testname) {
// mkdtemp requires that the last 6 characters of the input pattern
// are Xs, and the string is modified by replacing those characters.
std::string pattern = "/tmp/" + testname + "_XXXXXX";
GTEST_CHECK_(mkdtemp(pattern.data()) != nullptr);
dirname_ = pattern;
}
~MakeTempDir() { GTEST_CHECK_POSIX_SUCCESS_(rmdir(dirname_.c_str())); }
const char* DirName() const { return dirname_.c_str(); }
private:
std::string dirname_;
};
bool StartsWith(const std::string& str, const std::string& prefix) {
return str.substr(0, prefix.size()) == prefix;
}
TEST(TempDirTest, InEnvironment) {
// Since the test infrastructure might be verifying directory existence or
// even creating subdirectories, we need to be careful that the directories we
// specify are actually valid.
MakeTempDir temp_dir("TempDirTest_InEnvironment");
SetEnv set_env("TEST_TMPDIR", temp_dir.DirName());
EXPECT_TRUE(StartsWith(testing::TempDir(), temp_dir.DirName()));
}
TEST(TempDirTest, NotInEnvironment) {
SetEnv set_env("TEST_TMPDIR", nullptr);
EXPECT_NE(testing::TempDir(), "");
}
TEST(SrcDirTest, InEnvironment) {
// Since the test infrastructure might be verifying directory existence or
// even creating subdirectories, we need to be careful that the directories we
// specify are actually valid.
MakeTempDir temp_dir("SrcDirTest_InEnvironment");
SetEnv set_env("TEST_SRCDIR", temp_dir.DirName());
EXPECT_TRUE(StartsWith(testing::SrcDir(), temp_dir.DirName()));
}
TEST(SrcDirTest, NotInEnvironment) {
SetEnv set_env("TEST_SRCDIR", nullptr);
EXPECT_NE(testing::SrcDir(), "");
}
} // namespace
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: ''
---
**Describe the bug**
Include a clear and concise description of what the problem is, including what
you expected to happen, and what actually happened.
**Steps to reproduce the bug**
It's important that we are able to reproduce the problem that you are
experiencing. Please provide all code and relevant steps to reproduce the
problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links
to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the
problem are also helpful.
**Does the bug persist in the most recent commit?**
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.
**What compiler and version are you using?**
Please include the output of `gcc -v` or `clang -v`, or the equivalent for your
compiler.
**What build system are you using?**
Please include the output of `bazel --version` or `cmake --version`, or the
equivalent for your build system.
**Additional context**
Add any other context about the problem here.
---
name: Feature request
about: Propose a new feature
title: ''
labels: 'enhancement'
assignees: ''
---
**Does the feature exist in the most recent commit?**
We recommend using the latest commit from GitHub in your projects.
**Why do we need this feature?**
Ideally, explain why a combination of existing features cannot be used instead.
**Describe the proposal**
Include a detailed description of the feature, with usage examples.
**Is the feature specific to an operating system, compiler, or build system version?**
If it is, please specify which versions.
...@@ -4,40 +4,37 @@ on: ...@@ -4,40 +4,37 @@ on:
push: push:
pull_request: pull_request:
env:
BAZEL_CXXOPTS: -std=c++14
jobs: jobs:
Linux: Linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Tests - name: Tests
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... run: bazel test --test_output=errors //...
macOS: MacOs:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Tests - name: Tests
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... run: bazel test --test_output=errors //...
Windows: Windows:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Tests - name: Tests
run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ... run: bazel test --test_output=errors //...
...@@ -7,16 +7,12 @@ if (POLICY CMP0048) ...@@ -7,16 +7,12 @@ if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048) endif (POLICY CMP0048)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif (POLICY CMP0069)
if (POLICY CMP0077) if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) cmake_policy(SET CMP0077 NEW)
endif (POLICY CMP0077) endif (POLICY CMP0077)
project(googletest-distribution) project(googletest-distribution)
set(GOOGLETEST_VERSION 1.13.0) set(GOOGLETEST_VERSION 1.12.1)
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
...@@ -30,7 +26,6 @@ include(GNUInstallDirs) ...@@ -30,7 +26,6 @@ include(GNUInstallDirs)
#Note that googlemock target already builds googletest #Note that googlemock target already builds googletest
option(BUILD_GMOCK "Builds the googlemock subproject" ON) option(BUILD_GMOCK "Builds the googlemock subproject" ON)
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF)
if(BUILD_GMOCK) if(BUILD_GMOCK)
add_subdirectory( googlemock ) add_subdirectory( googlemock )
......
...@@ -80,8 +80,8 @@ fairly rigid coding style, as defined by the ...@@ -80,8 +80,8 @@ fairly rigid coding style, as defined by the
[google-styleguide](https://github.com/google/styleguide) project. All patches [google-styleguide](https://github.com/google/styleguide) project. All patches
will be expected to conform to the style outlined will be expected to conform to the style outlined
[here](https://google.github.io/styleguide/cppguide.html). Use [here](https://google.github.io/styleguide/cppguide.html). Use
[.clang-format](https://github.com/google/googletest/blob/main/.clang-format) to [.clang-format](https://github.com/google/googletest/blob/master/.clang-format)
check your formatting. to check your formatting.
## Requirements for Contributors ## Requirements for Contributors
......
...@@ -15,14 +15,11 @@ Our documentation is now live on GitHub Pages at ...@@ -15,14 +15,11 @@ Our documentation is now live on GitHub Pages at
https://google.github.io/googletest/. We recommend browsing the documentation on https://google.github.io/googletest/. We recommend browsing the documentation on
GitHub Pages rather than directly in the repository. GitHub Pages rather than directly in the repository.
#### Release 1.12.1 #### Release 1.11.0
[Release 1.12.1](https://github.com/google/googletest/releases/tag/release-1.12.1) [Release 1.11.0](https://github.com/google/googletest/releases/tag/release-1.11.0)
is now available. is now available.
The 1.12.x branch will be the last to support C++11. Future releases will
require at least C++14.
#### Coming Soon #### Coming Soon
* We are planning to take a dependency on * We are planning to take a dependency on
...@@ -59,12 +56,39 @@ More information about building GoogleTest can be found at ...@@ -59,12 +56,39 @@ More information about building GoogleTest can be found at
## Supported Platforms ## Supported Platforms
GoogleTest follows Google's GoogleTest requires a codebase and compiler compliant with the C++11 standard or
[Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support). newer.
See
[this table](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md) The GoogleTest code is officially supported on the following platforms.
for a list of currently supported versions compilers, platforms, and build Operating systems or tools not listed below are community-supported. For
tools. 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/)
**Note:** 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.
## Who Is Using GoogleTest? ## Who Is Using GoogleTest?
...@@ -111,7 +135,7 @@ that generates stub code for GoogleTest. ...@@ -111,7 +135,7 @@ that generates stub code for GoogleTest.
## Contributing Changes ## Contributing Changes
Please read Please read
[`CONTRIBUTING.md`](https://github.com/google/googletest/blob/main/CONTRIBUTING.md) [`CONTRIBUTING.md`](https://github.com/google/googletest/blob/master/CONTRIBUTING.md)
for details on how to contribute to this project. for details on how to contribute to this project.
Happy testing! Happy testing!
workspace(name = "com_google_googletest")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_absl",
sha256 = "1a1745b5ee81392f5ea4371a4ca41e55d446eeaee122903b2eaffbd8a3b67a2b",
strip_prefix = "abseil-cpp-01cc6567cff77738e416a7ddc17de2d435a780ce",
urls = ["https://github.com/abseil/abseil-cpp/archive/01cc6567cff77738e416a7ddc17de2d435a780ce.zip"], # 2022-06-21T19:28:27Z
)
# Note this must use a commit from the `abseil` branch of the RE2 project.
# https://github.com/google/re2/tree/abseil
http_archive(
name = "com_googlesource_code_re2",
sha256 = "0a890c2aa0bb05b2ce906a15efb520d0f5ad4c7d37b8db959c43772802991887",
strip_prefix = "re2-a427f10b9fb4622dd6d8643032600aa1b50fbd12",
urls = ["https://github.com/google/re2/archive/a427f10b9fb4622dd6d8643032600aa1b50fbd12.zip"], # 2022-06-09
)
http_archive(
name = "rules_python",
sha256 = "0b460f17771258341528753b1679335b629d1d25e3af28eda47d009c103a6e15",
strip_prefix = "rules_python-aef17ad72919d184e5edb7abf61509eb78e57eda",
urls = ["https://github.com/bazelbuild/rules_python/archive/aef17ad72919d184e5edb7abf61509eb78e57eda.zip"], # 2022-06-21T23:44:47Z
)
http_archive(
name = "bazel_skylib",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz"],
sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
)
http_archive(
name = "platforms",
sha256 = "a879ea428c6d56ab0ec18224f976515948822451473a80d06c2e50af0bbe5121",
strip_prefix = "platforms-da5541f26b7de1dc8e04c075c99df5351742a4a2",
urls = ["https://github.com/bazelbuild/platforms/archive/da5541f26b7de1dc8e04c075c99df5351742a4a2.zip"], # 2022-05-27
)
...@@ -39,7 +39,7 @@ if [[ -z ${GTEST_ROOT:-} ]]; then ...@@ -39,7 +39,7 @@ if [[ -z ${GTEST_ROOT:-} ]]; then
fi fi
if [[ -z ${STD:-} ]]; then if [[ -z ${STD:-} ]]; then
STD="c++14 c++17 c++20" STD="c++11 c++14 c++17 c++20"
fi fi
# Test the CMake build # Test the CMake build
...@@ -55,7 +55,7 @@ for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do ...@@ -55,7 +55,7 @@ for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do
${LINUX_LATEST_CONTAINER} \ ${LINUX_LATEST_CONTAINER} \
/bin/bash -c " /bin/bash -c "
cmake /src \ cmake /src \
-DCMAKE_CXX_STANDARD=14 \ -DCMAKE_CXX_STANDARD=11 \
-Dgtest_build_samples=ON \ -Dgtest_build_samples=ON \
-Dgtest_build_tests=ON \ -Dgtest_build_tests=ON \
-Dgmock_build_tests=ON \ -Dgmock_build_tests=ON \
...@@ -72,7 +72,6 @@ time docker run \ ...@@ -72,7 +72,6 @@ time docker run \
--workdir="/src" \ --workdir="/src" \
--rm \ --rm \
--env="CC=/usr/local/bin/gcc" \ --env="CC=/usr/local/bin/gcc" \
--env="BAZEL_CXXOPTS=-std=c++14" \
${LINUX_GCC_FLOOR_CONTAINER} \ ${LINUX_GCC_FLOOR_CONTAINER} \
/usr/local/bin/bazel test ... \ /usr/local/bin/bazel test ... \
--copt="-Wall" \ --copt="-Wall" \
...@@ -80,7 +79,6 @@ time docker run \ ...@@ -80,7 +79,6 @@ time docker run \
--copt="-Wuninitialized" \ --copt="-Wuninitialized" \
--copt="-Wno-error=pragmas" \ --copt="-Wno-error=pragmas" \
--distdir="/bazel-distdir" \ --distdir="/bazel-distdir" \
--features=external_include_paths \
--keep_going \ --keep_going \
--show_timestamps \ --show_timestamps \
--test_output=errors --test_output=errors
...@@ -101,7 +99,6 @@ for std in ${STD}; do ...@@ -101,7 +99,6 @@ for std in ${STD}; do
--copt="-Wuninitialized" \ --copt="-Wuninitialized" \
--define="absl=${absl}" \ --define="absl=${absl}" \
--distdir="/bazel-distdir" \ --distdir="/bazel-distdir" \
--features=external_include_paths \
--keep_going \ --keep_going \
--show_timestamps \ --show_timestamps \
--test_output=errors --test_output=errors
...@@ -125,7 +122,6 @@ for std in ${STD}; do ...@@ -125,7 +122,6 @@ for std in ${STD}; do
--copt="-Wuninitialized" \ --copt="-Wuninitialized" \
--define="absl=${absl}" \ --define="absl=${absl}" \
--distdir="/bazel-distdir" \ --distdir="/bazel-distdir" \
--features=external_include_paths \
--keep_going \ --keep_going \
--linkopt="--gcc-toolchain=/usr/local" \ --linkopt="--gcc-toolchain=/usr/local" \
--show_timestamps \ --show_timestamps \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment