summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml14
-rw-r--r--CONTRIBUTING.md20
-rwxr-xr-xci/assert-docs.sh6
-rwxr-xr-xci/assert-no-diff.sh8
-rwxr-xr-xci/assert-rustfmt.sh16
-rwxr-xr-xci/test.sh26
-rw-r--r--src/ir/objc.rs1
7 files changed, 71 insertions, 20 deletions
diff --git a/.travis.yml b/.travis.yml
index 47af4eeb..4dd55c86 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,17 +25,9 @@ cache:
before_install: . ./ci/before_install.sh
script:
- - cargo test --features "$BINDGEN_FEATURES assert_no_dangling_items"
- - cargo test --release --features "$BINDGEN_FEATURES assert_no_dangling_items"
- - git add -A
- - git diff @
- - git diff-index --quiet HEAD
- - cargo build --features "$BINDGEN_FEATURES docs_"
- - cd tests/expectations
- - cargo test
- - cd ../../bindgen-integration
- - cargo test --features "$BINDGEN_FEATURES"
- - cargo test --release --features "$BINDGEN_FEATURES"
+ - ./ci/assert-rustfmt.sh
+ - BINDGEN_FEATURES="$BINDGEN_FEATURES" ./ci/assert-docs.sh
+ - BINDGEN_FEATURES="$BINDGEN_FEATURES" ./ci/test.sh
notifications:
webhooks: http://build.servo.org:54856/travis
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index cfcee653..9ee1b4ac 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -114,24 +114,26 @@ $ cargo test -p tests_expectations
## Automatic code formatting
-There's a `rustfmt.toml` file in the repo. Ideally changes should be consistent
-with the style, though that's not enforced right now.
+We use [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt) to enforce a
+consistent code style across the whole `bindgen` code base. This is enforced in
+CI, and your pull requests will get automatically rejected if you don't
+re-format with the latest `rustfmt` before pushing.
-[`rustfmt`](https://github.com/rust-lang-nursery/rustfmt) can catch and fix
-automatically all the coding style issues it finds. In order to use it it
-suffices to do:
+You can install the latest version of `rustfmt` with this command:
```
-$ cargo fmt
+$ cargo install -f rustfmt
```
-For it to work, you need to have `rustfmt` installed. To do so:
+Ensure that `~/.cargo/bin` is on your path.
+
+Once that is taken care of, you can (re)format all code by running this command:
```
-$ cargo install rustfmt
+$ cargo fmt
```
-And ensure `~/.cargo/bin` is on your path.
+The code style is described in the `rustfmt.toml` file in top level of the repo.
## Debug Logging
diff --git a/ci/assert-docs.sh b/ci/assert-docs.sh
new file mode 100755
index 00000000..aa4b90ac
--- /dev/null
+++ b/ci/assert-docs.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -xeu
+cd "$(dirname "$0")/.."
+
+cargo build --features "$BINDGEN_FEATURES docs_"
diff --git a/ci/assert-no-diff.sh b/ci/assert-no-diff.sh
new file mode 100755
index 00000000..14f2aa21
--- /dev/null
+++ b/ci/assert-no-diff.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+set -xeu
+cd "$(dirname "$0")/.."
+
+git add -u
+git diff @
+git diff-index --quiet HEAD
diff --git a/ci/assert-rustfmt.sh b/ci/assert-rustfmt.sh
new file mode 100755
index 00000000..bd268600
--- /dev/null
+++ b/ci/assert-rustfmt.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -xeu
+cd "$(dirname "$0")/.."
+
+# Ensure we have the most up-to-date `rustfmt`.
+cargo install -f rustfmt
+
+# Run `rustfmt` on the crate! If `rustfmt` can't make a long line shorter, it
+# prints an error and exits non-zero, so tell it to kindly shut its yapper and
+# make sure it doesn't cause us to exit this whole script non-zero.
+cargo fmt --quiet || true
+
+# Exit non-zero if this resulted in any diffs.
+./ci/assert-no-diff.sh
+
diff --git a/ci/test.sh b/ci/test.sh
new file mode 100755
index 00000000..9bfccfd8
--- /dev/null
+++ b/ci/test.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -xeu
+cd "$(dirname "$0")/.."
+
+# Regenerate the test headers' bindings in debug and release modes, and assert
+# that we always get the expected generated bindings.
+
+cargo test --features "$BINDGEN_FEATURES assert_no_dangling_items"
+./ci/assert-no-diff.sh
+
+cargo test --release --features "$BINDGEN_FEATURES assert_no_dangling_items"
+./ci/assert-no-diff.sh
+
+# Now test the expectations' size and alignment tests.
+
+pushd tests/expectations
+cargo test
+cargo test --release
+popd
+
+# And finally, test our example bindgen + build.rs integration template project.
+
+cd bindgen-integration
+cargo test --features "$BINDGEN_FEATURES"
+cargo test --release --features "$BINDGEN_FEATURES"
diff --git a/src/ir/objc.rs b/src/ir/objc.rs
index 92356d92..08cab1cc 100644
--- a/src/ir/objc.rs
+++ b/src/ir/objc.rs
@@ -1,6 +1,7 @@
//! Objective C types
// use clang_sys::CXCursor_ObjCSuperClassRef;
+
use super::context::BindgenContext;
use clang;
use clang_sys::CXChildVisit_Continue;