Skip to content

Commit 7cb1250

Browse files
committed
Add a CONTRIBUTING.md file
It provides an overview of how to file a helpful issue and how to run tests. Fixes #93
1 parent 82a74d0 commit 7cb1250

File tree

2 files changed

+86
-6
lines changed

2 files changed

+86
-6
lines changed

CONTRIBUTING.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Contributing to `servo/rust-bindgen`
2+
3+
Hi! We'd love to have your contributions! If you want help or mentorship, reach
4+
out to us in a GitHub issue, or stop by #servo on irc.mozilla.org and introduce
5+
yourself.
6+
7+
* [Code of Conduct](#coc)
8+
* [Filing an Issue](#issue)
9+
* [Building](#building)
10+
* [Testing](#tests)
11+
* [Overview](#tests-overview)
12+
* [Running All Tests](#tests-all)
13+
* [Running a Single, Specific Test](#tests-one)
14+
* [Authoring New Tests](#tests-new)
15+
16+
## Code of Conduct <span id="coc"/>
17+
18+
We abide by the [Rust Code of Conduct][coc] and ask that you do as well.
19+
20+
[coc]: https://www.rust-lang.org/en-US/conduct.html
21+
22+
## Filing an Issue <span id="issue"/>
23+
24+
Think you've found a bug? File an issue! To help us understand and reproduce the
25+
issue, provide us with:
26+
27+
* A reduced C/C++ header file that reproduces the issue
28+
* The `bindgen` flags used to reproduce the issue with the header file
29+
* The expected `bindgen` output
30+
* The actual `bindgen` output
31+
32+
## Building <span id="building"/>
33+
34+
Build instructions are in the [README](./README.md).
35+
36+
## Testing <span id="tests"/>
37+
38+
### Overview <span id="tests-overview"/>
39+
40+
Input C/C++ test headers reside in the `tests/headers` directory. The expected
41+
output rust bindings live in `tests/expectations`; for example,
42+
`tests/headers/my_header.h`'s expected generated rust bindings would be
43+
`tests/expectations/my_header.rs`.
44+
45+
The `tests/tools/run-bindgen.py` script runs `bindgen` on the test headers and
46+
compares the results to the expectations.
47+
48+
### Running All Tests <span id="tests-all"/>
49+
50+
```
51+
$ cargo test [--features llvm_stable]
52+
```
53+
54+
This spawns a `tests/tools/run-bindgen.py` subprocess for each test header.
55+
56+
### Running a Single, Specific Test <span id="tests-one"/>
57+
58+
```
59+
$ ./tests/tools/run-bindgen.py ./target/debug/bindgen ./tests/headers/some_header.h
60+
```
61+
62+
To learn more about the options available with `run-bindgen.py`:
63+
64+
```
65+
$ ./tests/tools/run-bindgen.py --help
66+
```
67+
68+
### Authoring New Tests <span id="tests-new"/>
69+
70+
To add a new test header to the suite, simply put it in the `tests/headers`
71+
directory. Next, run the `run-bindgen.py` script with the new test header, which
72+
will generate the initial expected output rust bindings.
73+
74+
If your new test requires certain flags to be passed to `bindgen`, you can
75+
specify them at the top of the test header, with a comment like this:
76+
77+
```c
78+
// bindgen-flags: --enable-cxx-namespaces -- -std=c++14
79+
```
80+
81+
If your new test requires `bindgen` to be built with certain features, you can
82+
specify the required features at the top of the test header in a similar manner:
83+
84+
```c
85+
// bingden-features: llvm_stable
86+
```

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ $ LIBCLANG_PATH=path/to/clang-3.9/build/lib \
7676
cargo build
7777
```
7878

79-
## Running Tests
80-
81-
```
82-
$ make test
83-
```
84-
8579
# Command Line Usage
8680

8781
There are a few options documented when running `./bindgen --help`. Other

0 commit comments

Comments
 (0)