CONTRIBUTING.md 5.5 KB
Newer Older
1 2 3 4
# How to become a contributor and submit your own code

## Contributor License Agreements

J
jiyong_sd 已提交
5 6
We'd love to accept your patches! Before we can take them, we have to jump a
couple of legal hurdles.
7 8 9 10

Please fill out either the individual or corporate Contributor License Agreement
(CLA).

J
jiyong_sd 已提交
11
*   If you are an individual writing original source code and you're sure you
12 13
    own the intellectual property, then you'll need to sign an
    [individual CLA](https://developers.google.com/open-source/cla/individual).
J
jiyong_sd 已提交
14
*   If you work for a company that wants to allow you to contribute your work,
15 16 17 18 19 20 21
    then you'll need to sign a
    [corporate CLA](https://developers.google.com/open-source/cla/corporate).

Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.

G
Gennadiy Civil 已提交
22 23
## Are you a Googler?

J
jiyong_sd 已提交
24 25 26
If you are a Googler, please make an attempt to submit an internal change rather
than a GitHub Pull Request. If you are not able to submit an internal change a
PR is acceptable as an alternative.
G
Gennadiy Civil 已提交
27

28 29
## Contributing A Patch

J
jiyong_sd 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
1.  Submit an issue describing your proposed change to the
    [issue tracker](https://github.com/google/googletest/issues).
2.  Please don't mix more than one logical change per submittal, because it
    makes the history hard to follow. If you want to make a change that doesn't
    have a corresponding issue in the issue tracker, please create one.
3.  Also, coordinate with team members that are listed on the issue in question.
    This ensures that work isn't being duplicated and communicating your plan
    early also generally leads to better patches.
4.  If your proposed change is accepted, and you haven't already done so, sign a
    Contributor License Agreement (see details above).
5.  Fork the desired repo, develop and test your code changes.
6.  Ensure that your code adheres to the existing style in the sample to which
    you are contributing.
7.  Ensure that your code has an appropriate set of unit tests which all pass.
8.  Submit a pull request.

## The Google Test and Google Mock Communities
47 48

The Google Test community exists primarily through the
J
jiyong_sd 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
[discussion group](http://groups.google.com/group/googletestframework) and the
GitHub repository. Likewise, the Google Mock community exists primarily through
their own [discussion group](http://groups.google.com/group/googlemock). You are
definitely encouraged to contribute to the discussion and you can also help us
to keep the effectiveness of the group high by following and promoting the
guidelines listed here.

### Please Be Friendly

Showing courtesy and respect to others is a vital part of the Google culture,
and we strongly encourage everyone participating in Google Test development to
join us in accepting nothing less. Of course, being courteous is not the same as
failing to constructively disagree with each other, but it does mean that we
should be respectful of each other when enumerating the 42 technical reasons
that a particular proposal may not be the best choice. There's never a reason to
be antagonistic or dismissive toward anyone who is sincerely trying to
65 66
contribute to a discussion.

J
jiyong_sd 已提交
67 68 69
Sure, C++ testing is serious business and all that, but it's also a lot of fun.
Let's keep it that way. Let's strive to be one of the friendliest communities in
all of open source.
70

J
jiyong_sd 已提交
71 72
As always, discuss Google Test in the official GoogleTest discussion group. You
don't have to actually submit code in order to sign up. Your participation
73 74
itself is a valuable contribution.

75 76
## Style

J
jiyong_sd 已提交
77 78 79 80 81 82 83
To keep the source consistent, readable, diffable and easy to merge, we use a
fairly rigid coding style, as defined by the
[google-styleguide](https://github.com/google/styleguide) project. All patches
will be expected to conform to the style outlined
[here](https://google.github.io/styleguide/cppguide.html). Use
[.clang-format](https://github.com/google/googletest/blob/master/.clang-format)
to check your formatting.
84

J
jiyong_sd 已提交
85
## Requirements for Contributors
86

J
jiyong_sd 已提交
87 88
If you plan to contribute a patch, you need to build Google Test, Google Mock,
and their own tests from a git checkout, which has further requirements:
89

J
jiyong_sd 已提交
90 91 92
*   [Python](https://www.python.org/) v2.3 or newer (for running some of the
    tests and re-generating certain source files from templates)
*   [CMake](https://cmake.org/) v2.8.12 or newer
93

J
jiyong_sd 已提交
94
## Developing Google Test and Google Mock
95

J
jiyong_sd 已提交
96
This section discusses how to make your own changes to the Google Test project.
97

J
jiyong_sd 已提交
98
### Testing Google Test and Google Mock Themselves
99 100

To make sure your changes work as intended and don't break existing
J
jiyong_sd 已提交
101 102
functionality, you'll want to compile and run Google Test and GoogleMock's own
tests. For that you can use CMake:
103 104 105

    mkdir mybuild
    cd mybuild
J
jiyong_sd 已提交
106
    cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR}
107

J
jiyong_sd 已提交
108 109
To choose between building only Google Test or Google Mock, you may modify your
cmake command to be one of each
110

J
jiyong_sd 已提交
111 112
    cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests
    cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests
113

J
jiyong_sd 已提交
114 115 116 117
Make sure you have Python installed, as some of Google Test's tests are written
in Python. If the cmake command complains about not being able to find Python
(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it
explicitly where your Python executable can be found:
118

J
jiyong_sd 已提交
119
    cmake -DPYTHON_EXECUTABLE=path/to/python ...
120

J
jiyong_sd 已提交
121 122
Next, you can build Google Test and / or Google Mock and all desired tests. On
\*nix, this is usually done by
123

J
jiyong_sd 已提交
124
    make
125

J
jiyong_sd 已提交
126
To run the tests, do
127

J
jiyong_sd 已提交
128
    make test
129

J
jiyong_sd 已提交
130
All tests should pass.