Skip to content

Commit

Permalink
Pulling updates from masters (#2)
Browse files Browse the repository at this point in the history
* Correct some typos in a comment

* fix small typo in comment

* add note about different definitions of Test Case

There are contradictory definitions of the term "test case", so prepare
new users in Primer.md to avoid confusion.

* Samples changes upstreaming

* Samples changes upstreaming

* WIP

* WIP, windows testing

* WIP, windows testing

* WIP, windows testing

* WIP, win testing

* WIP, win testing

* Punctuation

Missing periods

* be more specific on Test Case

* WIP

* Added googlemock tests

* Added googlemock tests

* Infinite Loop when calling a mock function that takes boost::filesystem::path as parameter google#521: Add is_same type trait

* Infinite Loop when calling a mock function that takes boost::filesystem::path as parameter google#521: Add is_same type trait and prevent infinite loops for recursive containers

* WIP

* Fix library install destinations

Modify library install destinations to install .dll's to the correct
location (`bin`, not `lib`), and to install other artifacts to the
correct platform-dependent location by using GNUInstallDirs. This is
required for some distributions (e.g. Fedora) and will fix an issue that
otherwise requires those distributions to patch the upstream sources.
Also, add options to suppress installation, which may be useful for
projects that embed Google Test.

Since Google Test is trying to support archaic versions of CMake, a
brain-dead fallback (which requires that the user set either LIB_SUFFIX
or CMAKE_INSTALL_LIBDIR themselves) is included for versions that
predate GNUInstallDirs.

Fixes google#1161.

Co-Authored-By: d3x0r <d3x0r@users.noreply.github.com>

* clarify distinction regarding Test Case

* Adding a flag option to change the default mock type

* Initial Revision, review 164634031

* Added Copyright

* Minor style fixes

Typos, punctuation & broken links

* say "former version" instead of "released version"

* Update WORKSPACE

Remove comments

* Addressing comments

* Addressing Comments

* Add support for pkgconfig

* Add documentation for pkg-config

* Use GTEST_LOG instead of printf

* Removed extra colon in error log

* Change AppVeyor Status Badge to point to new AppVeyor Project Location

* Change AppVeyor Status Badge to point to new AppVeyor Project Location

* Fix problem installing gtest when gmock enabled

Fix a bug deciding whether to enable the option to install Google Test
caused by one of the dependent option dependencies not being defined
yet.

Fixes google#1198; impossible to install Google Test if Google Mock is built.

* Add function name to exception if there's no default action

* Handling invalid flag values

* Update README.md

Another AppVeyor move

* adds test for NiceMock with unknown return value

* Fix test if exceptions are not supported

* Switch return type to class without default constructor

* Change tabs to spaces in test case

* Adding CMake visibility policy setting

This policy setting will silence a warning when using with a visibility settings on targets. Due to the forced `cmake_minimum_version`, policy settings in CMakeLists calling this one (including the main CMakeLists) are lost, forcing the change to be made here.

* Proposing these changes, please review

Slightly better names and cleaner tests.
Please review

* Added "explicit" as per compiler suggestion

* Remove unused variable

* Support ref-qualified member functions in Property().

* Support x64 configuration for old VS2010 projects

VS2010 solution only to simplify old users (who used these solutions) upgrading to new gtest/gmock, new users should use CMake generated solutions. VS2010 solution can be opened in any new VS.

* Remove gtest VS2005 projects

* Support x64 configuration for old VS2015 projects

* Applying lint checks from upstream google3

* fix typo in comment and string (SetUpTestCase)

* remove unused TestCase import

* fix typo: xUnit

* remove non-existing gmock_build_samples switch

* switch on verbose make

* run combined build only

There is no need for separate 'googlemock' and 'googletest' builds,
as the 'googlemock' build includes 'googletest' and it's unit tests.

* remove Yob's comma mentioned in issue google#1105

* use plural verb as mentioned in issue google#1105

* Detect Fuchsia, and set GTEST_HAS_PTHREAD on GTEST_OS_FUCHSIA

* use build type set in .travis.yml

The BUILD_TYPE variable of .travis.yml was ignored up to now.

* use upper-case build type

While cmake does not complain on build type 'debug', the cmake
documentation always spells it 'Debug', so take this.

* fix SetUp/TearDownTestCase() in AdvancedGuide

fixes issue google#1087

* remove obsolete comment regarding python tests on linux

* ask cmake for per-configuration output subdir

On single-configuration build systems as Makefile Generators, there is
no subdirectory for the configuration in the build tree - therefore ask
cmake for the subdir by using CMAKE_CFG_INTDIR, which is just '.' on
single-configuration build systems (Linux et al.).

* Revert "ask cmake for per-configuration output subdir"

This reverts commit 73d58dd.

Unfortunately, ${CMAKE_CFG_INTDIR} is set during build only and doesn't
help here.

* create different python based tests for single and multi configuration build generators

* Note that it is preferable for Googlers to create a CL internally first

* removed internal link ( not allowed in OSS)

* Removed "Trivial" 

Who knows? may not be very trivial given the code drift between internal and OSS

* AppVeyor MinGW-w64 test build

* fix example's comment

* change links from former code.google.com to current github repository

* CMake: use threads if allowed and found, not just if found.

If the user's cmakelists.txt first look for threads using
find_package(Threads), then set(gtest_disable_pthreads ON),
and then include googletest. GoogleTest will not look for
threads. But since they have already been found before in
user's cmakelists, it will use them regardless.

This helped me fix build issue in darktable-org/rawspeed
on windows/MSYS2, even though there are threads, and they
are usable, googletest build was failing with issues
about AutoHandle. I was first looking for threads, and only
then including googletest, so no matter the value of
gtest_disable_pthreads, it failed.

The other obvious solution is for user to first include
googletest, and only then look for threads by himself.

* switch one build to Release mode

This turns on optimization which allows the compiler to discover more
problems and omit some more warnings.

* treat all warnings as errors for GCC (-Werror)

* Allow macros inside of parametrized test names.

This allows doing things like TEST_P(TestFixture, MAYBE(TestName)) for nicer conditional test disabling.

* Add a non-parametrized test.

* avoid -Wshadow warning on GCC

When using INSTANTIATE_TEST_CASE_P with a lambda function which uses
'info' as parameter name, GCC complains that this would shadow
parameter 'info' used in the macro's VA_ARGS call.

* avoid warning about unused variable

* cache ccache

* set MAKEFLAGS to use multiple processors on Travis CI

* install ccache on travis osx build slave

* limit processors to use in Travis build to 4

* remove obsolete link_directories command

It's not necessary, as the target_link_libraries command contains an
absolute path already, and the path given doesn't exist anymore,
leading only to linker warnings like:
ld: warning: directory not found for option
'-L/Users/travis/build/google/googletest/build/googlemock/gtest/src'

* add a cast

* show ccache statistics in log

* call clang via ccache on Linux

* reset ccache statistics at install

* drop unused valgrind package from installation

... and remove explicit gcc installation (will be installed with g++
automatically)

* remove unused variables from travis environment

* Removed flush scopes around GTEST_LOG(FATAL) and exit call since FATAL is expected to abort()

* use GTEST_ATTRIBUTE_UNUSED_ instead of dummy function

* Fix ellipsis position in examples

* Make the failure messages from EXPECT_EQ and friends actually symmetric,

instead of reading more like reversing the former "expected" and "actual"
roles of the LHS and RHS arguments.

This patch is manually applied from internal version (125109873)

* Add explicit `CMAKE_DEBUG_POSTFIX` option

Enable generating different library name to be compatible with CMake's `FindGTest`.

* Remove redundant declaration

TempDir() function is declared twice, once in `internal/gtest-port.h`
and a second time in `gtest.h`.

Fixes a warning with GCC when -Wredundant-decls is given.

* Swap reinterpret_cast for static_cast

Swap reinterpret_cast for static_cast

* Revert "Allow macros inside of parametrized test names."

* Use gender-neutral pronouns in comments and docs

* Updated README with information about C runtime dynamic/static linking issues in Windows

* google#1282: Doc typo fix

* Workaround for Travis issue travis-ci/travis-ci#8552

* Revert "Workaround for Travis issue https://github.com/travis-ci/travis-ci/is…"

* Workaround for Travis issue https://goo.gl/d5eV8o

* googletest: Add GTEST_API_ attribute to ThreadLocal class.

ThreadLocal class needs to be have default visibility.
Root cause is gtest uses typeinfo for the ThreadLocal class.
The problem manifests When gtest/gmock are built as a shared library
with libc++. When a class is used in typeinfo, it must have default
visibility.

There is an explanation about typeinfo and visibility here:
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

When libc++ is used with gtest in shared library mode, any tests
that are compiled with -fvisibility=hidden and exercise the
macro EXPECT_CALL, it results in an abort like:
[ FATAL ] /usr/include/gtest/internal/gtest-port.h:1394::
Condition typeid(*base) == typeid(Derived) failed.
This is because the typeinfo for ThreadLocal class is not visible.
Therefore, linker failed to match it to the shared library symbol, creating a
new symbol instead.

This fixes google#1207.

* Enable C++11 features for VS2015 and VS2017

* Fix tests with VS2015 and VS2017

* Fix gmock tests when std::unary_function unavailable

* Remove gcc 6 misleading indentations.

* Enable CI for VS2017

* remove markdown stars (bold) from code examples

* Fixes issue google#826 by treating MinGW as "non-Windows" when determining colored output
  • Loading branch information
FrankieLi committed Dec 6, 2017
1 parent 3bd9572 commit a2af3c5
Show file tree
Hide file tree
Showing 180 changed files with 4,507 additions and 29,004 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# Ignore CI build directory
build/
xcuserdata
cmake-build-debug/
.idea/
bazel-bin
bazel-genfiles
bazel-googletest
bazel-out
bazel-testlogs
# python
*.pyc

# Visual Studio files
*.sdf
*.opensdf
*.VC.opendb
*.suo
*.user
_ReSharper.Caches/
Win32-Debug/
Win32-Release/
x64-Debug/
x64-Release/
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ install:
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
# /usr/bin/clang is 3.4, lets override with modern one.
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi
# ccache on OS X needs installation first
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
# reset ccache statistics
- ccache --zero-stats
- echo ${PATH}
- echo ${CXX}
- ${CXX} --version
Expand All @@ -22,25 +26,24 @@ addons:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- gcc-4.9
- g++-4.9
- clang-3.7
- valgrind
os:
- linux
- osx
language: cpp
cache: ccache
before_cache:
# print statistics before uploading new cache
- ccache --show-stats
compiler:
- gcc
- clang
script: ./travis.sh
env:
matrix:
- GTEST_TARGET=googletest SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
- GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
- GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug CXX_FLAGS=-std=c++11 VERBOSE_MAKE=true VERBOSE
# - GTEST_TARGET=googletest SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
# - GTEST_TARGET=googlemock SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
- BUILD_TYPE=Debug VERBOSE=1
- BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
notifications:
email: false
sudo: false
147 changes: 147 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Copyright 2017 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.
#
# Author: misterg@google.com (Gennadiy Civil)
#
# Bazel Build for Google C++ Testing Framework(Google Test)

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

config_setting(
name = "win",
values = {"cpu": "x64_windows_msvc"},
)

# Google Test including Google Mock
cc_library(
name = "gtest",
srcs = glob(
include = [
"googletest/src/*.cc",
"googletest/src/*.h",
"googletest/include/gtest/**/*.h",
"googlemock/src/*.cc",
"googlemock/include/gmock/**/*.h",
],
exclude = [
"googletest/src/gtest-all.cc",
"googletest/src/gtest_main.cc",
"googlemock/src/gmock-all.cc",
"googlemock/src/gmock_main.cc",
],
),
hdrs =glob([
"googletest/include/gtest/*.h",
"googlemock/include/gmock/*.h",
]),
copts = select(
{
":win": [],
"//conditions:default": ["-pthread"],
},
),
includes = [
"googlemock",
"googlemock/include",
"googletest",
"googletest/include",
],
linkopts = select({
":win": [],
"//conditions:default": [
"-pthread",
],
}),
)

cc_library(
name = "gtest_main",
srcs = [
"googlemock/src/gmock_main.cc",
],
deps = ["//:gtest"],
)

# The following rules build samples of how to use gTest.
cc_library(
name = "gtest_sample_lib",
srcs = [
"googletest/samples/sample1.cc",
"googletest/samples/sample2.cc",
"googletest/samples/sample4.cc",
],
hdrs = [
"googletest/samples/prime_tables.h",
"googletest/samples/sample1.h",
"googletest/samples/sample2.h",
"googletest/samples/sample3-inl.h",
"googletest/samples/sample4.h",
],
)

cc_test(
name = "gtest_samples",
size = "small",
#All Samples except:
#sample9 ( main )
#sample10 (main and takes a command line option and needs to be separate)
srcs = [
"googletest/samples/sample1_unittest.cc",
"googletest/samples/sample2_unittest.cc",
"googletest/samples/sample3_unittest.cc",
"googletest/samples/sample4_unittest.cc",
"googletest/samples/sample5_unittest.cc",
"googletest/samples/sample6_unittest.cc",
"googletest/samples/sample7_unittest.cc",
"googletest/samples/sample8_unittest.cc",
],
deps = [
"gtest_sample_lib",
":gtest_main",
],
)

cc_test(
name = "sample9_unittest",
size = "small",
srcs = ["googletest/samples/sample9_unittest.cc"],
deps = [":gtest"],
)

cc_test(
name = "sample10_unittest",
size = "small",
srcs = ["googletest/samples/sample10_unittest.cc"],
deps = [
":gtest",
],
)
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 2.6.2)
cmake_minimum_required(VERSION 2.6.4)

if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)

project( googletest )

Expand All @@ -8,11 +12,24 @@ set(CPACK_PACKAGE_VERSION_PATCH 0)

enable_testing()

include(CMakeDependentOption)
if (CMAKE_VERSION VERSION_LESS 2.8.5)
set(CMAKE_INSTALL_BINDIR "bin" CACHE STRING "User executables (bin)")
set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}" CACHE STRING "Object code libraries (lib)")
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE STRING "C header files (include)")
mark_as_advanced(CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR)
else()
include(GNUInstallDirs)
endif()

option(BUILD_GTEST "Builds the googletest subproject" OFF)

#Note that googlemock target already builds googletest
option(BUILD_GMOCK "Builds the googlemock subproject" ON)

cmake_dependent_option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON "BUILD_GTEST OR BUILD_GMOCK" OFF)
cmake_dependent_option(INSTALL_GMOCK "Enable installation of googlemock. (Projects embedding googlemock may want to turn this OFF.)" ON "BUILD_GMOCK" OFF)

if(BUILD_GMOCK)
add_subdirectory( googlemock )
elseif(BUILD_GTEST)
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Google Test #

[![Build Status](https://travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest)
[![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/BillyDonahue/googletest/branch/master)
[![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master)

Welcome to **Google Test**, Google's C++ test framework!

Expand All @@ -12,7 +12,7 @@ maintain and release them together.

Please see the project page above for more information as well as the
mailing list for questions, discussions, and development. There is
also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please
also an IRC channel on [OFTC](https://webchat.oftc.net/) (irc.oftc.net) #gtest available. Please
join us!

Getting started information for **Google Test** is available in the
Expand All @@ -26,7 +26,7 @@ in its interior [googletest/README.md](googletest/README.md) file.

## Features ##

* An [XUnit](https://en.wikipedia.org/wiki/XUnit) test framework.
* An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework.
* Test discovery.
* A rich set of assertions.
* User-defined assertions.
Expand Down Expand Up @@ -60,9 +60,12 @@ the following notable projects:
* [Protocol Buffers](https://github.com/google/protobuf), Google's data
interchange format.
* The [OpenCV](http://opencv.org/) computer vision library.
* [tiny-dnn](https://github.com/tiny-dnn/tiny-dnn): header only, dependency-free deep learning framework in C++11.

## Related Open Source Projects ##

[GTest Runner](https://github.com/nholthaus/gtest-runner) is a Qt5 based automated test-runner and Graphical User Interface with powerful features for Windows and Linux platforms.

[Google Test UI](https://github.com/ospector/gtest-gbar) is test runner that runs
your test binary, allows you to track its progress via a progress bar, and
displays a list of test failures. Clicking on one shows failure text. Google
Expand All @@ -73,6 +76,9 @@ listener for Google Test that implements the
[TAP protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) for test
result output. If your test runner understands TAP, you may find it useful.

[gtest-parallel](https://github.com/google/gtest-parallel) is a test runner that
runs tests from your binary in parallel to provide significant speed-up.

## Requirements ##

Google Test is designed to have fairly minimal requirements to build
Expand All @@ -82,7 +88,7 @@ effort to support other platforms (e.g. Solaris, AIX, and z/OS).
However, since core members of the Google Test project have no access
to these platforms, Google Test may have outstanding issues there. If
you notice any problems on your platform, please notify
<googletestframework@googlegroups.com>. Patches for fixing them are
[googletestframework@googlegroups.com](https://groups.google.com/forum/#!forum/googletestframework). Patches for fixing them are
even more welcome!

### Linux Requirements ###
Expand All @@ -97,7 +103,7 @@ package (as described below):

### Windows Requirements ###

* Microsoft Visual C++ v7.1 or newer
* Microsoft Visual C++ 2010 or newer

### Cygwin Requirements ###

Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace(name = "com_google_googletest")
Loading

0 comments on commit a2af3c5

Please sign in to comment.