Skip to content

Commit 9700f61

Browse files
fitzgenKowasaki
authored andcommitted
Clean up testing-only cargo features
This commit ensures that all of the cargo features we have that only exist for CI/testing purposes, and aren't for external consumption, have a "testing_only_" prefix.
1 parent eaa2c24 commit 9700f61

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ $ export LD_LIBRARY_PATH=path/to/clang-3.9/lib # for Linux
6565
$ export DYLD_LIBRARY_PATH=path/to/clang-3.9/lib # for macOS
6666
```
6767

68-
Additionally, you may want to build and test with the `docs_` feature to ensure
69-
that you aren't forgetting to document types and functions. CI will catch it if
70-
you forget, but the turn around will be a lot slower ;)
68+
Additionally, you may want to build and test with the `testing_only_docs`
69+
feature to ensure that you aren't forgetting to document types and functions. CI
70+
will catch it if you forget, but the turn around will be a lot slower ;)
7171

7272
```
73-
$ cargo build --features docs_
73+
$ cargo build --features testing_only_docs
7474
```
7575

7676
## Testing

Cargo.toml

+6-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ features = ["with-syntex"]
6565
version = "0.29"
6666

6767
[features]
68-
assert_no_dangling_items = []
6968
default = ["logging"]
70-
testing_only_llvm_stable = []
7169
logging = ["env_logger", "log"]
7270
static = []
73-
# This feature only exists for CI -- don't use it!
74-
docs_ = []
71+
72+
# These features only exist for CI testing -- don't use them if you're not hacking
73+
# on bindgen!
74+
testing_only_assert_no_dangling_items = []
75+
testing_only_docs = []
76+
testing_only_llvm_stable = []

ci/assert-docs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set -xeu
44
cd "$(dirname "$0")/.."
55

6-
cargo build --features "$BINDGEN_FEATURES docs_"
6+
cargo build --features "$BINDGEN_FEATURES testing_only_docs"

ci/test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ cd "$(dirname "$0")/.."
66
# Regenerate the test headers' bindings in debug and release modes, and assert
77
# that we always get the expected generated bindings.
88

9-
cargo test --features "$BINDGEN_FEATURES assert_no_dangling_items"
9+
cargo test --features "$BINDGEN_FEATURES testing_only_assert_no_dangling_items"
1010
./ci/assert-no-diff.sh
1111

12-
cargo test --release --features "$BINDGEN_FEATURES assert_no_dangling_items"
12+
cargo test --release --features "$BINDGEN_FEATURES testing_only_assert_no_dangling_items"
1313
./ci/assert-no-diff.sh
1414

1515
# Now test the expectations' size and alignment tests.

src/ir/context.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,12 @@ impl<'ctx> BindgenContext<'ctx> {
584584
ret
585585
}
586586

587-
/// This function trying to find any dangling references inside of `items`
587+
/// When the `testing_only_assert_no_dangling_items` feature is enabled,
588+
/// this function walks the IR graph and asserts that we do not have any
589+
/// edges referencing an ItemId for which we do not have an associated IR
590+
/// item.
588591
fn assert_no_dangling_references(&self) {
589-
if cfg!(feature = "assert_no_dangling_items") {
592+
if cfg!(feature = "testing_only_assert_no_dangling_items") {
590593
for _ in self.assert_no_dangling_item_traversal() {
591594
// The iterator's next method does the asserting for us.
592595
}

src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ extern crate log;
3838
mod log_stubs;
3939

4040
// A macro to declare an internal module for which we *must* provide
41-
// documentation for. If we are building with the "docs_" feature, then the
42-
// module is declared public, and our `#![deny(missing_docs)]` pragma applies to
43-
// it. This feature is used in CI, so we won't let anything slip by
41+
// documentation for. If we are building with the "testing_only_docs" feature,
42+
// then the module is declared public, and our `#![deny(missing_docs)]` pragma
43+
// applies to it. This feature is used in CI, so we won't let anything slip by
4444
// undocumented. Normal builds, however, will leave the module private, so that
4545
// we don't expose internals to library consumers.
4646
macro_rules! doc_mod {
4747
($m:ident, $doc_mod_name:ident) => {
4848
cfg_if! {
49-
if #[cfg(feature = "docs_")] {
49+
if #[cfg(feature = "testing_only_docs")] {
5050
pub mod $doc_mod_name {
5151
//! Autogenerated documentation module.
5252
pub use super::$m::*;

0 commit comments

Comments
 (0)