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). 82 83## Requirements for Contributors ### 84 85If you plan to contribute a patch, you need to build Google Test, 86Google Mock, and their own tests from a git checkout, which has 87further requirements: 88 89 * [Python](https://www.python.org/) v2.3 or newer (for running some of 90 the tests and re-generating certain source files from templates) 91 * [CMake](https://cmake.org/) v2.6.4 or newer 92 * [GNU Build System](https://en.wikipedia.org/wiki/GNU_Build_System) 93 including automake (>= 1.9), autoconf (>= 2.59), and 94 libtool / libtoolize. 95 96## Developing Google Test ## 97 98This section discusses how to make your own changes to Google Test. 99 100### Testing Google Test Itself ### 101 102To make sure your changes work as intended and don't break existing 103functionality, you'll want to compile and run Google Test's own tests. 104For that you can use CMake: 105 106 mkdir mybuild 107 cd mybuild 108 cmake -Dgtest_build_tests=ON ${GTEST_DIR} 109 110Make sure you have Python installed, as some of Google Test's tests 111are written in Python. If the cmake command complains about not being 112able to find Python (`Could NOT find PythonInterp (missing: 113PYTHON_EXECUTABLE)`), try telling it explicitly where your Python 114executable can be found: 115 116 cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR} 117 118Next, you can build Google Test and all of its own tests. On \*nix, 119this is usually done by 'make'. To run the tests, do 120 121 make test 122 123All tests should pass. 124 125### Regenerating Source Files ## 126 127Some of Google Test's source files are generated from templates (not 128in the C++ sense) using a script. 129For example, the 130file include/gtest/internal/gtest-type-util.h.pump is used to generate 131gtest-type-util.h in the same directory. 132 133You don't need to worry about regenerating the source files 134unless you need to modify them. You would then modify the 135corresponding `.pump` files and run the '[pump.py](googletest/scripts/pump.py)' 136generator script. See the [Pump Manual](googletest/docs/PumpManual.md). 137 138## Developing Google Mock ### 139 140This section discusses how to make your own changes to Google Mock. 141 142#### Testing Google Mock Itself #### 143 144To make sure your changes work as intended and don't break existing 145functionality, you'll want to compile and run Google Test's own tests. 146For that you'll need Autotools. First, make sure you have followed 147the instructions above to configure Google Mock. 148Then, create a build output directory and enter it. Next, 149 150 ${GMOCK_DIR}/configure # try --help for more info 151 152Once you have successfully configured Google Mock, the build steps are 153standard for GNU-style OSS packages. 154 155 make # Standard makefile following GNU conventions 156 make check # Builds and runs all tests - all should pass. 157 158Note that when building your project against Google Mock, you are building 159against Google Test as well. There is no need to configure Google Test 160separately. 161