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