Skip to content

Commit 9100016

Browse files
committed
#1: add google test as local lib
1 parent db0e250 commit 9100016

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+41714
-36
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CMAKE_BUILD_TYPE=Release
44

55
FOO_BUILD_DIR=/opt/foo/build
66
FOO_OUTPUT_DIR=/opt/foo/output
7+
FOO_TESTS_ENABLED=ON
78
FOO_RUN_TESTS=ON
89
# Temporary: Turn off coverage reporting (requires lcov but not yet in DARMA/workflows setup requirements)
910
FOO_COVERAGE_ENABLED=OFF

lib/fetch_googletest.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
GTEST_BRANCHTAG=release-1.12.1
4+
5+
# Fetch googletest from Github.
6+
LIB_DIR="$(dirname -- "$(realpath -- "$0")")"
7+
GTEST_DIR="${LIB_DIR}/googletest"
8+
9+
echo "LIB_DIR=$LIB_DIR"
10+
11+
mkdir -p $GTEST_DIR && rm -fr $GTEST_DIR/*
12+
curl -L https://github.com/google/googletest/archive/refs/tags/$GTEST_BRANCHTAG.tar.gz \
13+
| tar zxf - -C $GTEST_DIR --strip-components 1
14+
15+
# Remove googletest artifacts - set cmake BUILD_GMOCK=0, don't install, don't build test.
16+
pushd $GTEST_DIR
17+
rm -fr .[!.]* BUILD.bazel WORKSPACE appveyor.yml library.json platformio.ini
18+
rm -fr ci/
19+
rm -fr googletest/test/ googletest/samples/ googletest/docs/ googletest/scripts/
20+
rm -fr googlemock/test/ googlemock/samples/ googlemock/docs/ googlemock/scripts/
21+
rm -fr docs
22+
popd

lib/googletest/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Note: CMake support is community-based. The maintainers do not use CMake
2+
# internally.
3+
4+
cmake_minimum_required(VERSION 3.5)
5+
6+
if (POLICY CMP0048)
7+
cmake_policy(SET CMP0048 NEW)
8+
endif (POLICY CMP0048)
9+
10+
if (POLICY CMP0077)
11+
cmake_policy(SET CMP0077 NEW)
12+
endif (POLICY CMP0077)
13+
14+
project(googletest-distribution)
15+
set(GOOGLETEST_VERSION 1.12.1)
16+
17+
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
18+
set(CMAKE_CXX_EXTENSIONS OFF)
19+
endif()
20+
21+
enable_testing()
22+
23+
include(CMakeDependentOption)
24+
include(GNUInstallDirs)
25+
26+
#Note that googlemock target already builds googletest
27+
option(BUILD_GMOCK "Builds the googlemock subproject" ON)
28+
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
29+
30+
if(BUILD_GMOCK)
31+
add_subdirectory( googlemock )
32+
else()
33+
add_subdirectory( googletest )
34+
endif()

lib/googletest/CONTRIBUTING.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# How to become a contributor and submit your own code
2+
3+
## Contributor License Agreements
4+
5+
We'd love to accept your patches! Before we can take them, we have to jump a
6+
couple of legal hurdles.
7+
8+
Please fill out either the individual or corporate Contributor License Agreement
9+
(CLA).
10+
11+
* If you are an individual writing original source code and you're sure you
12+
own the intellectual property, then you'll need to sign an
13+
[individual CLA](https://developers.google.com/open-source/cla/individual).
14+
* If you work for a company that wants to allow you to contribute your work,
15+
then you'll need to sign a
16+
[corporate CLA](https://developers.google.com/open-source/cla/corporate).
17+
18+
Follow either of the two links above to access the appropriate CLA and
19+
instructions for how to sign and return it. Once we receive it, we'll be able to
20+
accept your pull requests.
21+
22+
## Are you a Googler?
23+
24+
If you are a Googler, please make an attempt to submit an internal contribution
25+
rather than a GitHub Pull Request. If you are not able to submit internally, a
26+
PR is acceptable as an alternative.
27+
28+
## Contributing A Patch
29+
30+
1. Submit an issue describing your proposed change to the
31+
[issue tracker](https://github.com/google/googletest/issues).
32+
2. Please don't mix more than one logical change per submittal, because it
33+
makes the history hard to follow. If you want to make a change that doesn't
34+
have a corresponding issue in the issue tracker, please create one.
35+
3. Also, coordinate with team members that are listed on the issue in question.
36+
This ensures that work isn't being duplicated and communicating your plan
37+
early also generally leads to better patches.
38+
4. If your proposed change is accepted, and you haven't already done so, sign a
39+
Contributor License Agreement
40+
([see details above](#contributor-license-agreements)).
41+
5. Fork the desired repo, develop and test your code changes.
42+
6. Ensure that your code adheres to the existing style in the sample to which
43+
you are contributing.
44+
7. Ensure that your code has an appropriate set of unit tests which all pass.
45+
8. Submit a pull request.
46+
47+
## The Google Test and Google Mock Communities
48+
49+
The Google Test community exists primarily through the
50+
[discussion group](http://groups.google.com/group/googletestframework) and the
51+
GitHub repository. Likewise, the Google Mock community exists primarily through
52+
their own [discussion group](http://groups.google.com/group/googlemock). You are
53+
definitely encouraged to contribute to the discussion and you can also help us
54+
to keep the effectiveness of the group high by following and promoting the
55+
guidelines listed here.
56+
57+
### Please Be Friendly
58+
59+
Showing courtesy and respect to others is a vital part of the Google culture,
60+
and we strongly encourage everyone participating in Google Test development to
61+
join us in accepting nothing less. Of course, being courteous is not the same as
62+
failing to constructively disagree with each other, but it does mean that we
63+
should be respectful of each other when enumerating the 42 technical reasons
64+
that a particular proposal may not be the best choice. There's never a reason to
65+
be antagonistic or dismissive toward anyone who is sincerely trying to
66+
contribute to a discussion.
67+
68+
Sure, C++ testing is serious business and all that, but it's also a lot of fun.
69+
Let's keep it that way. Let's strive to be one of the friendliest communities in
70+
all of open source.
71+
72+
As always, discuss Google Test in the official GoogleTest discussion group. You
73+
don't have to actually submit code in order to sign up. Your participation
74+
itself is a valuable contribution.
75+
76+
## Style
77+
78+
To keep the source consistent, readable, diffable and easy to merge, we use a
79+
fairly rigid coding style, as defined by the
80+
[google-styleguide](https://github.com/google/styleguide) project. All patches
81+
will be expected to conform to the style outlined
82+
[here](https://google.github.io/styleguide/cppguide.html). Use
83+
[.clang-format](https://github.com/google/googletest/blob/master/.clang-format)
84+
to check your formatting.
85+
86+
## Requirements for Contributors
87+
88+
If you plan to contribute a patch, you need to build Google Test, Google Mock,
89+
and their own tests from a git checkout, which has further requirements:
90+
91+
* [Python](https://www.python.org/) v2.3 or newer (for running some of the
92+
tests and re-generating certain source files from templates)
93+
* [CMake](https://cmake.org/) v2.8.12 or newer
94+
95+
## Developing Google Test and Google Mock
96+
97+
This section discusses how to make your own changes to the Google Test project.
98+
99+
### Testing Google Test and Google Mock Themselves
100+
101+
To make sure your changes work as intended and don't break existing
102+
functionality, you'll want to compile and run Google Test and GoogleMock's own
103+
tests. For that you can use CMake:
104+
105+
mkdir mybuild
106+
cd mybuild
107+
cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR}
108+
109+
To choose between building only Google Test or Google Mock, you may modify your
110+
cmake command to be one of each
111+
112+
cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests
113+
cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests
114+
115+
Make sure you have Python installed, as some of Google Test's tests are written
116+
in Python. If the cmake command complains about not being able to find Python
117+
(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it
118+
explicitly where your Python executable can be found:
119+
120+
cmake -DPYTHON_EXECUTABLE=path/to/python ...
121+
122+
Next, you can build Google Test and / or Google Mock and all desired tests. On
123+
\*nix, this is usually done by
124+
125+
make
126+
127+
To run the tests, do
128+
129+
make test
130+
131+
All tests should pass.

lib/googletest/CONTRIBUTORS

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This file contains a list of people who've made non-trivial
2+
# contribution to the Google C++ Testing Framework project. People
3+
# who commit code to the project are encouraged to add their names
4+
# here. Please keep the list sorted by first names.
5+
6+
Ajay Joshi <[email protected]>
7+
Balázs Dán <[email protected]>
8+
Benoit Sigoure <[email protected]>
9+
Bharat Mediratta <[email protected]>
10+
Bogdan Piloca <[email protected]>
11+
Chandler Carruth <[email protected]>
12+
Chris Prince <[email protected]>
13+
Chris Taylor <[email protected]>
14+
Dan Egnor <[email protected]>
15+
Dave MacLachlan <[email protected]>
16+
David Anderson <[email protected]>
17+
Dean Sturtevant
18+
Eric Roman <[email protected]>
19+
Gene Volovich <[email protected]>
20+
Hady Zalek <[email protected]>
21+
Hal Burch <[email protected]>
22+
Jeffrey Yasskin <[email protected]>
23+
Jim Keller <[email protected]>
24+
Joe Walnes <[email protected]>
25+
26+
Jói Sigurðsson <[email protected]>
27+
Keir Mierle <[email protected]>
28+
Keith Ray <[email protected]>
29+
Kenton Varda <[email protected]>
30+
Kostya Serebryany <[email protected]>
31+
Krystian Kuzniarek <[email protected]>
32+
Lev Makhlis
33+
Manuel Klimek <[email protected]>
34+
Mario Tanev <[email protected]>
35+
Mark Paskin
36+
Markus Heule <[email protected]>
37+
Martijn Vels <[email protected]>
38+
Matthew Simmons <[email protected]>
39+
Mika Raento <[email protected]>
40+
Mike Bland <[email protected]>
41+
Miklós Fazekas <[email protected]>
42+
Neal Norwitz <[email protected]>
43+
Nermin Ozkiranartli <[email protected]>
44+
Owen Carlsen <[email protected]>
45+
Paneendra Ba <[email protected]>
46+
Pasi Valminen <[email protected]>
47+
Patrick Hanna <[email protected]>
48+
Patrick Riley <[email protected]>
49+
Paul Menage <[email protected]>
50+
Peter Kaminski <[email protected]>
51+
Piotr Kaminski <[email protected]>
52+
Preston Jackson <[email protected]>
53+
Rainer Klaffenboeck <[email protected]>
54+
55+
Russ Rufer <[email protected]>
56+
Sean Mcafee <[email protected]>
57+
Sigurður Ásgeirsson <[email protected]>
58+
Sverre Sundsdal <[email protected]>
59+
Szymon Sobik <[email protected]>
60+
Takeshi Yoshino <[email protected]>
61+
Tracy Bialik <[email protected]>
62+
Vadim Berman <[email protected]>
63+
Vlad Losev <[email protected]>
64+
Wolfgang Klier <[email protected]>
65+
Zhanyong Wan <[email protected]>

lib/googletest/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright 2008, Google Inc.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above
11+
copyright notice, this list of conditions and the following disclaimer
12+
in the documentation and/or other materials provided with the
13+
distribution.
14+
* Neither the name of Google Inc. nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)