2017-12-09 04:20:55 +00:00
|
|
|
# How to become a contributor and submit your own code
|
|
|
|
|
|
|
|
## Contributor License Agreements
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
We'd love to accept your patches! Before we can take them, we have to jump a
|
|
|
|
couple of legal hurdles.
|
2017-12-09 04:20:55 +00:00
|
|
|
|
|
|
|
Please fill out either the individual or corporate Contributor License Agreement
|
|
|
|
(CLA).
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
* If you are an individual writing original source code and you're sure you
|
2017-12-09 04:20:55 +00:00
|
|
|
own the intellectual property, then you'll need to sign an
|
|
|
|
[individual CLA](https://developers.google.com/open-source/cla/individual).
|
2019-07-18 19:41:52 +00:00
|
|
|
* If you work for a company that wants to allow you to contribute your work,
|
2017-12-09 04:20:55 +00:00
|
|
|
then you'll need to sign a
|
|
|
|
[corporate CLA](https://developers.google.com/open-source/cla/corporate).
|
|
|
|
|
|
|
|
Follow either of the two links above to access the appropriate CLA and
|
|
|
|
instructions for how to sign and return it. Once we receive it, we'll be able to
|
|
|
|
accept your pull requests.
|
|
|
|
|
2018-08-20 20:08:33 +00:00
|
|
|
## Are you a Googler?
|
|
|
|
|
2019-07-26 09:48:08 +00:00
|
|
|
If you are a Googler, please make an attempt to submit an internal change rather
|
2019-07-18 19:41:52 +00:00
|
|
|
than a GitHub Pull Request. If you are not able to submit an internal change a
|
|
|
|
PR is acceptable as an alternative.
|
2018-08-20 20:08:33 +00:00
|
|
|
|
2017-12-09 04:20:55 +00:00
|
|
|
## Contributing A Patch
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
1. Submit an issue describing your proposed change to the
|
|
|
|
[issue tracker](https://github.com/google/googletest).
|
2019-07-26 12:46:27 +00:00
|
|
|
2. Please don't mix more than one logical change per submittal, because it
|
2019-07-18 19:41:52 +00:00
|
|
|
makes the history hard to follow. If you want to make a change that doesn't
|
|
|
|
have a corresponding issue in the issue tracker, please create one.
|
2019-07-26 12:46:27 +00:00
|
|
|
3. Also, coordinate with team members that are listed on the issue in question.
|
2019-07-18 19:41:52 +00:00
|
|
|
This ensures that work isn't being duplicated and communicating your plan
|
|
|
|
early also generally leads to better patches.
|
2019-07-26 12:46:27 +00:00
|
|
|
4. If your proposed change is accepted, and you haven't already done so, sign a
|
2019-07-18 19:41:52 +00:00
|
|
|
Contributor License Agreement (see details above).
|
2019-07-26 12:46:27 +00:00
|
|
|
5. Fork the desired repo, develop and test your code changes.
|
|
|
|
6. Ensure that your code adheres to the existing style in the sample to which
|
2019-07-18 19:41:52 +00:00
|
|
|
you are contributing.
|
2019-07-26 12:46:27 +00:00
|
|
|
7. Ensure that your code has an appropriate set of unit tests which all pass.
|
|
|
|
8. Submit a pull request.
|
2019-07-18 19:41:52 +00:00
|
|
|
|
|
|
|
## The Google Test and Google Mock Communities
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
The Google Test community exists primarily through the
|
2019-07-18 19:41:52 +00:00
|
|
|
[discussion group](http://groups.google.com/group/googletestframework) and the
|
|
|
|
GitHub repository. Likewise, the Google Mock community exists primarily through
|
|
|
|
their own [discussion group](http://groups.google.com/group/googlemock). You are
|
|
|
|
definitely encouraged to contribute to the discussion and you can also help us
|
|
|
|
to keep the effectiveness of the group high by following and promoting the
|
|
|
|
guidelines listed here.
|
|
|
|
|
|
|
|
### Please Be Friendly
|
|
|
|
|
|
|
|
Showing courtesy and respect to others is a vital part of the Google culture,
|
|
|
|
and we strongly encourage everyone participating in Google Test development to
|
|
|
|
join us in accepting nothing less. Of course, being courteous is not the same as
|
|
|
|
failing to constructively disagree with each other, but it does mean that we
|
|
|
|
should be respectful of each other when enumerating the 42 technical reasons
|
|
|
|
that a particular proposal may not be the best choice. There's never a reason to
|
|
|
|
be antagonistic or dismissive toward anyone who is sincerely trying to
|
2017-12-12 00:33:27 +00:00
|
|
|
contribute to a discussion.
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
Sure, C++ testing is serious business and all that, but it's also a lot of fun.
|
|
|
|
Let's keep it that way. Let's strive to be one of the friendliest communities in
|
|
|
|
all of open source.
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
As always, discuss Google Test in the official GoogleTest discussion group. You
|
|
|
|
don't have to actually submit code in order to sign up. Your participation
|
2017-12-12 00:33:27 +00:00
|
|
|
itself is a valuable contribution.
|
|
|
|
|
2017-12-09 04:20:55 +00:00
|
|
|
## Style
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
To keep the source consistent, readable, diffable and easy to merge, we use a
|
|
|
|
fairly rigid coding style, as defined by the
|
|
|
|
[google-styleguide](https://github.com/google/styleguide) project. All patches
|
|
|
|
will be expected to conform to the style outlined
|
|
|
|
[here](https://google.github.io/styleguide/cppguide.html). Use
|
|
|
|
[.clang-format](https://github.com/google/googletest/blob/master/.clang-format)
|
|
|
|
to check your formatting
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
## Requirements for Contributors
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
If you plan to contribute a patch, you need to build Google Test, Google Mock,
|
|
|
|
and their own tests from a git checkout, which has further requirements:
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
* [Python](https://www.python.org/) v2.3 or newer (for running some of the
|
|
|
|
tests and re-generating certain source files from templates)
|
|
|
|
* [CMake](https://cmake.org/) v2.6.4 or newer
|
|
|
|
* [GNU Build System](https://en.wikipedia.org/wiki/GNU_Build_System) including
|
|
|
|
automake (>= 1.9), autoconf (>= 2.59), and libtool / libtoolize.
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
## Developing Google Test
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
This section discusses how to make your own changes to Google Test.
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
### Testing Google Test Itself
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
To make sure your changes work as intended and don't break existing
|
2019-07-18 19:41:52 +00:00
|
|
|
functionality, you'll want to compile and run Google Test's own tests. For that
|
|
|
|
you can use CMake:
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
mkdir mybuild
|
|
|
|
cd mybuild
|
|
|
|
cmake -Dgtest_build_tests=ON ${GTEST_DIR}
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
Make sure you have Python installed, as some of Google Test's tests are written
|
|
|
|
in Python. If the cmake command complains about not being able to find Python
|
|
|
|
(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it
|
|
|
|
explicitly where your Python executable can be found:
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
Next, you can build Google Test and all of its own tests. On \*nix, this is
|
|
|
|
usually done by 'make'. To run the tests, do
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
make test
|
|
|
|
|
|
|
|
All tests should pass.
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
### Regenerating Source Files
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
Some of Google Test's source files are generated from templates (not in the C++
|
|
|
|
sense) using a script. For example, the file
|
|
|
|
include/gtest/internal/gtest-type-util.h.pump is used to generate
|
2017-12-12 00:33:27 +00:00
|
|
|
gtest-type-util.h in the same directory.
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
You don't need to worry about regenerating the source files unless you need to
|
|
|
|
modify them. You would then modify the corresponding `.pump` files and run the
|
|
|
|
'[pump.py](googletest/scripts/pump.py)' generator script. See the
|
2019-07-29 14:42:41 +00:00
|
|
|
[Pump Manual](googletest/docs/PumpManual.md).
|
2017-12-12 00:33:27 +00:00
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
## Developing Google Mock
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
This section discusses how to make your own changes to Google Mock.
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
#### Testing Google Mock Itself
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
To make sure your changes work as intended and don't break existing
|
2019-07-18 19:41:52 +00:00
|
|
|
functionality, you'll want to compile and run Google Test's own tests. For that
|
|
|
|
you'll need Autotools. First, make sure you have followed the instructions above
|
|
|
|
to configure Google Mock. Then, create a build output directory and enter it.
|
|
|
|
Next,
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
${GMOCK_DIR}/configure # try --help for more info
|
|
|
|
|
2019-07-18 19:41:52 +00:00
|
|
|
Once you have successfully configured Google Mock, the build steps are standard
|
|
|
|
for GNU-style OSS packages.
|
2017-12-12 00:33:27 +00:00
|
|
|
|
|
|
|
make # Standard makefile following GNU conventions
|
|
|
|
make check # Builds and runs all tests - all should pass.
|
|
|
|
|
|
|
|
Note that when building your project against Google Mock, you are building
|
2019-07-18 19:41:52 +00:00
|
|
|
against Google Test as well. There is no need to configure Google Test
|
2017-12-12 00:33:27 +00:00
|
|
|
separately.
|