Skip to content

Commit 8ebeef4

Browse files
amanjeevemilio
authored andcommitted
fix: test runner for fuzzy tests and update documentation
Signed-off-by: Amanjeev Sethi <[email protected]>
1 parent 5875949 commit 8ebeef4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

CONTRIBUTING.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ $ cargo build --features testing_only_docs
8686

8787
### Overview
8888

89-
Input C/C++ test headers reside in the `tests/headers` directory. Expected
90-
output Rust bindings live in `tests/expectations/tests`. For example,
91-
`tests/headers/my_header.h`'s expected generated Rust bindings would be
92-
`tests/expectations/tests/my_header.rs`.
89+
Input C/C++ test headers reside in the `bindgen-tests/tests/headers` directory. Expected
90+
output Rust bindings live in `bindgen-tests/tests/expectations/tests`. For example,
91+
`bindgen-tests/tests/headers/my_header.h`'s expected generated Rust bindings would be
92+
`bindgen-tests/tests/expectations/tests/my_header.rs`.
9393

9494
There are also some integration tests in the `./bindgen-integration` crate, which uses `bindgen` to
9595
generate bindings to some C++ code, and then uses the bindings, asserting that
@@ -109,8 +109,8 @@ These steps must be performed manually when needed.
109109

110110
### Testing Bindings Generation
111111

112-
To regenerate bindings from the corpus of test headers in `tests/headers` and
113-
compare them against the expected bindings in `tests/expectations/tests`, run:
112+
To regenerate bindings from the corpus of test headers in `bindgen-tests/tests/headers` and
113+
compare them against the expected bindings in `bindgen-tests/tests/expectations/tests`, run:
114114

115115
```
116116
$ cargo test
@@ -139,14 +139,14 @@ those.
139139
### Testing Generated Bindings
140140

141141
If your local changes are introducing expected modifications in the
142-
`tests/expectations/tests/*` bindings files, then you should test that the
142+
`bindgen-tests/tests/expectations/tests/*` bindings files, then you should test that the
143143
generated bindings files still compile, and that their struct layout tests still
144144
pass. Also, run the integration tests (see below).
145145

146146
You can do this with these commands:
147147

148148
```
149-
$ cd tests/expectations
149+
$ cd bindgen-tests/tests/expectations
150150
$ cargo test
151151
```
152152

@@ -157,22 +157,22 @@ is a dependency for running `test-one.sh`.
157157

158158
Sometimes its useful to work with one test header from start (generating
159159
bindings for it) to finish (compiling the bindings and running their layout
160-
tests). This can be done with the `tests/test-one.sh` script. It supports fuzzy
160+
tests). This can be done with the `bindgen-tests/tests/test-one.sh` script. It supports fuzzy
161161
searching for test headers. For example, to test
162162
`tests/headers/what_is_going_on.hpp`, execute this command:
163163

164164
```
165-
$ ./tests/test-one.sh going
165+
$ ./bindgen-tests/tests/test-one.sh going
166166
```
167167

168168
Note that `test-one.sh` does not recompile `bindgen`, so if you change the code,
169169
you'll need to rebuild it before running the script again.
170170

171171
### Authoring New Tests
172172

173-
To add a new test header to the suite, simply put it in the `tests/headers`
173+
To add a new test header to the suite, simply put it in the `bindgen-tests/tests/headers`
174174
directory. Next, run `bindgen` to generate the initial expected output Rust
175-
bindings. Put those in `tests/expectations/tests`.
175+
bindings. Put those in `bindgen-tests/tests/expectations/tests`.
176176

177177
If your new test requires certain flags to be passed to `bindgen`, you can
178178
specify them at the top of the test header, with a comment like this:
@@ -186,7 +186,7 @@ specify them at the top of the test header, with a comment like this:
186186
Then verify the new Rust bindings compile and pass their layout tests:
187187

188188
```
189-
$ cd tests/expectations
189+
$ cd bindgen-tests/tests/expectations
190190
$ cargo test new_test_header
191191
```
192192

@@ -195,11 +195,11 @@ $ cargo test new_test_header
195195
If a test generates different bindings across different `libclang` versions (for
196196
example, because we take advantage of better/newer APIs when possible), then you
197197
can add multiple test expectations, one for each supported `libclang`
198-
version. Instead of having a single `tests/expectations/tests/my_test.rs` file,
198+
version. Instead of having a single `bindgen-tests/tests/expectations/tests/my_test.rs` file,
199199
add each of:
200200

201-
* `tests/expectations/tests/libclang-9/my_test.rs`
202-
* `tests/expectations/tests/libclang-5/my_test.rs`
201+
* `bindgen-tests/tests/expectations/tests/libclang-9/my_test.rs`
202+
* `bindgen-tests/tests/expectations/tests/libclang-5/my_test.rs`
203203

204204
If you need to update the test expectations for a test file that generates
205205
different bindings for different `libclang` versions, you *don't* need to have

bindgen-tests/tests/test-one.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ FLAGS="${FLAGS/\/\/ bindgen\-flags:/}"
4848
FLAGS="--rustfmt-bindings --with-derive-default --raw-line '' --raw-line '#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]' --raw-line '' $FLAGS"
4949

5050

51-
eval ./target/debug/bindgen \
51+
eval ../target/debug/bindgen \
5252
"\"$TEST\"" \
5353
--emit-ir \
5454
--emit-ir-graphviz ir.dot \

0 commit comments

Comments
 (0)