1# How to become a contributor and submit your own code
2
3## Contributor License Agreements
4
5We'd love to accept your patches! Before we can take them, we
6have to jump a couple of legal hurdles.
7
8Please 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
18Follow either of the two links above to access the appropriate CLA and
19instructions for how to sign and return it. Once we receive it, we'll be able to
20accept your pull requests.
21
22## Are you a Googler?
23If you are a Googler, you can either create an internal change or work on GitHub directly.
24
25
26## Contributing A Patch
27
281. Submit an issue describing your proposed change to the
29   [issue tracker](https://github.com/google/googletest).
301. Please don't mix more than one logical change per submittal,
31   because it makes the history hard to follow. If you want to make a
32   change that doesn't have a corresponding issue in the issue
33   tracker, please create one.
341. Also, coordinate with team members that are listed on the issue in
35   question. This ensures that work isn't being duplicated and
36   communicating your plan early also generally leads to better
37   patches.
381. If your proposed change is accepted, and you haven't already done so, sign a
39   Contributor License Agreement (see details above).
401. Fork the desired repo, develop and test your code changes.
411. Ensure that your code adheres to the existing style in the sample to which
42   you are contributing.
431. Ensure that your code has an appropriate set of unit tests which all pass.
441. Submit a pull request.
45
46## The Google Test and Google Mock Communities ##
47
48The Google Test community exists primarily through the
49[discussion group](http://groups.google.com/group/googletestframework)
50and the GitHub repository.
51Likewise, the Google Mock community exists primarily through their own
52[discussion group](http://groups.google.com/group/googlemock).
53You are definitely encouraged to contribute to the
54discussion and you can also help us to keep the effectiveness of the
55group high by following and promoting the guidelines listed here.
56
57### Please Be Friendly ###
58
59Showing courtesy and respect to others is a vital part of the Google
60culture, and we strongly encourage everyone participating in Google
61Test development to join us in accepting nothing less. Of course,
62being courteous is not the same as failing to constructively disagree
63with each other, but it does mean that we should be respectful of each
64other when enumerating the 42 technical reasons that a particular
65proposal may not be the best choice. There's never a reason to be
66antagonistic or dismissive toward anyone who is sincerely trying to
67contribute to a discussion.
68
69Sure, C++ testing is serious business and all that, but it's also
70a lot of fun. Let's keep it that way. Let's strive to be one of the
71friendliest communities in all of open source.
72
73As always, discuss Google Test in the official GoogleTest discussion group.
74You don't have to actually submit code in order to sign up. Your participation
75itself is a valuable contribution.
76
77## Style
78
79To keep the source consistent, readable, diffable and easy to merge,
80we use a fairly rigid coding style, as defined by the [google-styleguide](https://github.com/google/styleguide) project.  All patches will be expected
81to conform to the style outlined [here](https://google.github.io/styleguide/cppguide.html).
82Use [.clang-format](https://github.com/google/googletest/blob/master/.clang-format) to check your formatting
83
84## Requirements for Contributors ###
85
86If you plan to contribute a patch, you need to build Google Test,
87Google Mock, and their own tests from a git checkout, which has
88further requirements:
89
90  * [Python](https://www.python.org/) v2.3 or newer (for running some of
91    the tests and re-generating certain source files from templates)
92  * [CMake](https://cmake.org/) v2.6.4 or newer
93  * [GNU Build System](https://en.wikipedia.org/wiki/GNU_Build_System)
94    including automake (>= 1.9), autoconf (>= 2.59), and
95    libtool / libtoolize.
96
97## Developing Google Test ##
98
99This section discusses how to make your own changes to Google Test.
100
101### Testing Google Test Itself ###
102
103To make sure your changes work as intended and don't break existing
104functionality, you'll want to compile and run Google Test's own tests.
105For that you can use CMake:
106
107    mkdir mybuild
108    cd mybuild
109    cmake -Dgtest_build_tests=ON ${GTEST_DIR}
110
111Make sure you have Python installed, as some of Google Test's tests
112are written in Python.  If the cmake command complains about not being
113able to find Python (`Could NOT find PythonInterp (missing:
114PYTHON_EXECUTABLE)`), try telling it explicitly where your Python
115executable can be found:
116
117    cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
118
119Next, you can build Google Test and all of its own tests.  On \*nix,
120this is usually done by 'make'.  To run the tests, do
121
122    make test
123
124All tests should pass.
125
126### Regenerating Source Files ##
127
128Some of Google Test's source files are generated from templates (not
129in the C++ sense) using a script.
130For example, the
131file include/gtest/internal/gtest-type-util.h.pump is used to generate
132gtest-type-util.h in the same directory.
133
134You don't need to worry about regenerating the source files
135unless you need to modify them.  You would then modify the
136corresponding `.pump` files and run the '[pump.py](googletest/scripts/pump.py)'
137generator script.  See the [Pump Manual](googletest/docs/PumpManual.md).
138
139## Developing Google Mock ###
140
141This section discusses how to make your own changes to Google Mock.
142
143#### Testing Google Mock Itself ####
144
145To make sure your changes work as intended and don't break existing
146functionality, you'll want to compile and run Google Test's own tests.
147For that you'll need Autotools.  First, make sure you have followed
148the instructions above to configure Google Mock.
149Then, create a build output directory and enter it.  Next,
150
151    ${GMOCK_DIR}/configure  # try --help for more info
152
153Once you have successfully configured Google Mock, the build steps are
154standard for GNU-style OSS packages.
155
156    make        # Standard makefile following GNU conventions
157    make check  # Builds and runs all tests - all should pass.
158
159Note that when building your project against Google Mock, you are building
160against Google Test as well.  There is no need to configure Google Test
161separately.
162