da45e4450ce7f155f809f058b6f8a9d05d7642ce
[platform/upstream/gtest.git] / CONTRIBUTING.md
1 # How to become a contributor and submit your own code
2
3 ## Contributor License Agreements
4
5 We'd love to accept your patches! Before we can take them, we have to jump a
6 couple of legal hurdles.
7
8 Please 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
18 Follow either of the two links above to access the appropriate CLA and
19 instructions for how to sign and return it. Once we receive it, we'll be able to
20 accept your pull requests.
21
22 ## Are you a Googler?
23
24 If you are a Googler, please make an attempt to submit an internal change rather
25 than a GitHub Pull Request. If you are not able to submit an internal change a
26 PR is acceptable as an alternative.
27
28 ## Contributing A Patch
29
30 1.  Submit an issue describing your proposed change to the
31     [issue tracker](https://github.com/google/googletest/issues).
32 2.  Please don't mix more than one logical change per submittal, because it
33     makes the history hard to follow. If you want to make a change that doesn't
34     have a corresponding issue in the issue tracker, please create one.
35 3.  Also, coordinate with team members that are listed on the issue in question.
36     This ensures that work isn't being duplicated and communicating your plan
37     early also generally leads to better patches.
38 4.  If your proposed change is accepted, and you haven't already done so, sign a
39     Contributor License Agreement (see details above).
40 5.  Fork the desired repo, develop and test your code changes.
41 6.  Ensure that your code adheres to the existing style in the sample to which
42     you are contributing.
43 7.  Ensure that your code has an appropriate set of unit tests which all pass.
44 8.  Submit a pull request.
45
46 ## The Google Test and Google Mock Communities
47
48 The Google Test community exists primarily through the
49 [discussion group](http://groups.google.com/group/googletestframework) and the
50 GitHub repository. Likewise, the Google Mock community exists primarily through
51 their own [discussion group](http://groups.google.com/group/googlemock). You are
52 definitely encouraged to contribute to the discussion and you can also help us
53 to keep the effectiveness of the group high by following and promoting the
54 guidelines listed here.
55
56 ### Please Be Friendly
57
58 Showing courtesy and respect to others is a vital part of the Google culture,
59 and we strongly encourage everyone participating in Google Test development to
60 join us in accepting nothing less. Of course, being courteous is not the same as
61 failing to constructively disagree with each other, but it does mean that we
62 should be respectful of each other when enumerating the 42 technical reasons
63 that a particular proposal may not be the best choice. There's never a reason to
64 be antagonistic or dismissive toward anyone who is sincerely trying to
65 contribute to a discussion.
66
67 Sure, C++ testing is serious business and all that, but it's also a lot of fun.
68 Let's keep it that way. Let's strive to be one of the friendliest communities in
69 all of open source.
70
71 As always, discuss Google Test in the official GoogleTest discussion group. You
72 don't have to actually submit code in order to sign up. Your participation
73 itself is a valuable contribution.
74
75 ## Style
76
77 To keep the source consistent, readable, diffable and easy to merge, we use a
78 fairly rigid coding style, as defined by the
79 [google-styleguide](https://github.com/google/styleguide) project. All patches
80 will be expected to conform to the style outlined
81 [here](https://google.github.io/styleguide/cppguide.html). Use
82 [.clang-format](https://github.com/google/googletest/blob/master/.clang-format)
83 to check your formatting.
84
85 ## Requirements for Contributors
86
87 If you plan to contribute a patch, you need to build Google Test, Google Mock,
88 and their own tests from a git checkout, which has further requirements:
89
90 *   [Python](https://www.python.org/) v2.3 or newer (for running some of the
91     tests and re-generating certain source files from templates)
92 *   [CMake](https://cmake.org/) v2.8.12 or newer
93
94 ## Developing Google Test and Google Mock
95
96 This section discusses how to make your own changes to the Google Test project.
97
98 ### Testing Google Test and Google Mock Themselves
99
100 To make sure your changes work as intended and don't break existing
101 functionality, you'll want to compile and run Google Test and GoogleMock's own
102 tests. For that you can use CMake:
103
104     mkdir mybuild
105     cd mybuild
106     cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR}
107
108 To choose between building only Google Test or Google Mock, you may modify your
109 cmake command to be one of each
110
111     cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests
112     cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests
113
114 Make sure you have Python installed, as some of Google Test's tests are written
115 in Python. If the cmake command complains about not being able to find Python
116 (`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it
117 explicitly where your Python executable can be found:
118
119     cmake -DPYTHON_EXECUTABLE=path/to/python ...
120
121 Next, you can build Google Test and / or Google Mock and all desired tests. On
122 \*nix, this is usually done by
123
124     make
125
126 To run the tests, do
127
128     make test
129
130 All tests should pass.