xref: /freebsd/contrib/googletest/CONTRIBUTING.md (revision 5ca8c28cd8c725b81781201cfdb5f9969396f934)
1b89a7cc2SEnji Cooper# How to become a contributor and submit your own code
2b89a7cc2SEnji Cooper
3b89a7cc2SEnji Cooper## Contributor License Agreements
4b89a7cc2SEnji Cooper
528f6c2f2SEnji CooperWe'd love to accept your patches! Before we can take them, we have to jump a
628f6c2f2SEnji Coopercouple of legal hurdles.
7b89a7cc2SEnji Cooper
8b89a7cc2SEnji CooperPlease fill out either the individual or corporate Contributor License Agreement
9b89a7cc2SEnji Cooper(CLA).
10b89a7cc2SEnji Cooper
11b89a7cc2SEnji Cooper*   If you are an individual writing original source code and you're sure you
12b89a7cc2SEnji Cooper    own the intellectual property, then you'll need to sign an
13b89a7cc2SEnji Cooper    [individual CLA](https://developers.google.com/open-source/cla/individual).
14b89a7cc2SEnji Cooper*   If you work for a company that wants to allow you to contribute your work,
15b89a7cc2SEnji Cooper    then you'll need to sign a
16b89a7cc2SEnji Cooper    [corporate CLA](https://developers.google.com/open-source/cla/corporate).
17b89a7cc2SEnji Cooper
18b89a7cc2SEnji CooperFollow either of the two links above to access the appropriate CLA and
19b89a7cc2SEnji Cooperinstructions for how to sign and return it. Once we receive it, we'll be able to
20b89a7cc2SEnji Cooperaccept your pull requests.
21b89a7cc2SEnji Cooper
22b89a7cc2SEnji Cooper## Are you a Googler?
23b89a7cc2SEnji Cooper
2428f6c2f2SEnji CooperIf you are a Googler, please make an attempt to submit an internal contribution
2528f6c2f2SEnji Cooperrather than a GitHub Pull Request. If you are not able to submit internally, a
2628f6c2f2SEnji CooperPR is acceptable as an alternative.
27b89a7cc2SEnji Cooper
28b89a7cc2SEnji Cooper## Contributing A Patch
29b89a7cc2SEnji Cooper
30b89a7cc2SEnji Cooper1.  Submit an issue describing your proposed change to the
3128f6c2f2SEnji Cooper    [issue tracker](https://github.com/google/googletest/issues).
3228f6c2f2SEnji Cooper2.  Please don't mix more than one logical change per submittal, because it
3328f6c2f2SEnji Cooper    makes the history hard to follow. If you want to make a change that doesn't
3428f6c2f2SEnji Cooper    have a corresponding issue in the issue tracker, please create one.
3528f6c2f2SEnji Cooper3.  Also, coordinate with team members that are listed on the issue in question.
3628f6c2f2SEnji Cooper    This ensures that work isn't being duplicated and communicating your plan
3728f6c2f2SEnji Cooper    early also generally leads to better patches.
3828f6c2f2SEnji Cooper4.  If your proposed change is accepted, and you haven't already done so, sign a
3928f6c2f2SEnji Cooper    Contributor License Agreement
4028f6c2f2SEnji Cooper    ([see details above](#contributor-license-agreements)).
4128f6c2f2SEnji Cooper5.  Fork the desired repo, develop and test your code changes.
4228f6c2f2SEnji Cooper6.  Ensure that your code adheres to the existing style in the sample to which
43b89a7cc2SEnji Cooper    you are contributing.
4428f6c2f2SEnji Cooper7.  Ensure that your code has an appropriate set of unit tests which all pass.
4528f6c2f2SEnji Cooper8.  Submit a pull request.
46b89a7cc2SEnji Cooper
4728f6c2f2SEnji Cooper## The Google Test and Google Mock Communities
48b89a7cc2SEnji Cooper
49b89a7cc2SEnji CooperThe Google Test community exists primarily through the
50*5ca8c28cSEnji Cooper[discussion group](https://groups.google.com/group/googletestframework) and the
5128f6c2f2SEnji CooperGitHub repository. Likewise, the Google Mock community exists primarily through
52*5ca8c28cSEnji Coopertheir own [discussion group](https://groups.google.com/group/googlemock). You
53*5ca8c28cSEnji Cooperare definitely encouraged to contribute to the discussion and you can also help
54*5ca8c28cSEnji Cooperus to keep the effectiveness of the group high by following and promoting the
5528f6c2f2SEnji Cooperguidelines listed here.
56b89a7cc2SEnji Cooper
5728f6c2f2SEnji Cooper### Please Be Friendly
58b89a7cc2SEnji Cooper
5928f6c2f2SEnji CooperShowing courtesy and respect to others is a vital part of the Google culture,
6028f6c2f2SEnji Cooperand we strongly encourage everyone participating in Google Test development to
6128f6c2f2SEnji Cooperjoin us in accepting nothing less. Of course, being courteous is not the same as
6228f6c2f2SEnji Cooperfailing to constructively disagree with each other, but it does mean that we
6328f6c2f2SEnji Coopershould be respectful of each other when enumerating the 42 technical reasons
6428f6c2f2SEnji Cooperthat a particular proposal may not be the best choice. There's never a reason to
6528f6c2f2SEnji Cooperbe antagonistic or dismissive toward anyone who is sincerely trying to
66b89a7cc2SEnji Coopercontribute to a discussion.
67b89a7cc2SEnji Cooper
6828f6c2f2SEnji CooperSure, C++ testing is serious business and all that, but it's also a lot of fun.
6928f6c2f2SEnji CooperLet's keep it that way. Let's strive to be one of the friendliest communities in
7028f6c2f2SEnji Cooperall of open source.
71b89a7cc2SEnji Cooper
7228f6c2f2SEnji CooperAs always, discuss Google Test in the official GoogleTest discussion group. You
7328f6c2f2SEnji Cooperdon't have to actually submit code in order to sign up. Your participation
74b89a7cc2SEnji Cooperitself is a valuable contribution.
75b89a7cc2SEnji Cooper
76b89a7cc2SEnji Cooper## Style
77b89a7cc2SEnji Cooper
7828f6c2f2SEnji CooperTo keep the source consistent, readable, diffable and easy to merge, we use a
7928f6c2f2SEnji Cooperfairly rigid coding style, as defined by the
8028f6c2f2SEnji Cooper[google-styleguide](https://github.com/google/styleguide) project. All patches
8128f6c2f2SEnji Cooperwill be expected to conform to the style outlined
8228f6c2f2SEnji Cooper[here](https://google.github.io/styleguide/cppguide.html). Use
8328f6c2f2SEnji Cooper[.clang-format](https://github.com/google/googletest/blob/main/.clang-format) to
8428f6c2f2SEnji Coopercheck your formatting.
85b89a7cc2SEnji Cooper
8628f6c2f2SEnji Cooper## Requirements for Contributors
87b89a7cc2SEnji Cooper
8828f6c2f2SEnji CooperIf you plan to contribute a patch, you need to build Google Test, Google Mock,
8928f6c2f2SEnji Cooperand their own tests from a git checkout, which has further requirements:
90b89a7cc2SEnji Cooper
9128f6c2f2SEnji Cooper*   [Python](https://www.python.org/) v3.6 or newer (for running some of the
9228f6c2f2SEnji Cooper    tests and re-generating certain source files from templates)
9328f6c2f2SEnji Cooper*   [CMake](https://cmake.org/) v2.8.12 or newer
94b89a7cc2SEnji Cooper
9528f6c2f2SEnji Cooper## Developing Google Test and Google Mock
96b89a7cc2SEnji Cooper
9728f6c2f2SEnji CooperThis section discusses how to make your own changes to the Google Test project.
98b89a7cc2SEnji Cooper
9928f6c2f2SEnji Cooper### Testing Google Test and Google Mock Themselves
100b89a7cc2SEnji Cooper
101b89a7cc2SEnji CooperTo make sure your changes work as intended and don't break existing
10228f6c2f2SEnji Cooperfunctionality, you'll want to compile and run Google Test and GoogleMock's own
10328f6c2f2SEnji Coopertests. For that you can use CMake:
104b89a7cc2SEnji Cooper
10528f6c2f2SEnji Cooper```
106b89a7cc2SEnji Coopermkdir mybuild
107b89a7cc2SEnji Coopercd mybuild
10828f6c2f2SEnji Coopercmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR}
10928f6c2f2SEnji Cooper```
110b89a7cc2SEnji Cooper
11128f6c2f2SEnji CooperTo choose between building only Google Test or Google Mock, you may modify your
11228f6c2f2SEnji Coopercmake command to be one of each
113b89a7cc2SEnji Cooper
11428f6c2f2SEnji Cooper```
11528f6c2f2SEnji Coopercmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests
11628f6c2f2SEnji Coopercmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests
11728f6c2f2SEnji Cooper```
118b89a7cc2SEnji Cooper
11928f6c2f2SEnji CooperMake sure you have Python installed, as some of Google Test's tests are written
12028f6c2f2SEnji Cooperin Python. If the cmake command complains about not being able to find Python
12128f6c2f2SEnji Cooper(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it
12228f6c2f2SEnji Cooperexplicitly where your Python executable can be found:
123b89a7cc2SEnji Cooper
12428f6c2f2SEnji Cooper```
12528f6c2f2SEnji Coopercmake -DPYTHON_EXECUTABLE=path/to/python ...
12628f6c2f2SEnji Cooper```
12728f6c2f2SEnji Cooper
12828f6c2f2SEnji CooperNext, you can build Google Test and / or Google Mock and all desired tests. On
12928f6c2f2SEnji Cooper\*nix, this is usually done by
13028f6c2f2SEnji Cooper
13128f6c2f2SEnji Cooper```
13228f6c2f2SEnji Coopermake
13328f6c2f2SEnji Cooper```
13428f6c2f2SEnji Cooper
13528f6c2f2SEnji CooperTo run the tests, do
13628f6c2f2SEnji Cooper
13728f6c2f2SEnji Cooper```
138b89a7cc2SEnji Coopermake test
13928f6c2f2SEnji Cooper```
140b89a7cc2SEnji Cooper
141b89a7cc2SEnji CooperAll tests should pass.
142