diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-05-17 09:38:38 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-05-17 09:38:38 -0700 |
commit | a909b96c3e258ccd20535e8a16e6c88e058b25ef (patch) | |
tree | c02c9a1bc67269b03114c4f4b40c612c55df7818 | |
parent | 2588683ca55d96f331ed728d977eb8308ea56a8d (diff) |
Small improvements to test-one.sh
Allow running tests that don't have `bindgen-flags` pragmas. Less noisy
output. Show diff if the generated bindings differ from the expected bindings.
-rwxr-xr-x | tests/test-one.sh | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/test-one.sh b/tests/test-one.sh index cbb89eaf..a375a92e 100755 --- a/tests/test-one.sh +++ b/tests/test-one.sh @@ -8,7 +8,7 @@ # `rustc` to compile the bindings with unit tests enabled, and run the generated # layout tests. -set -eux +set -eu cd $(dirname $0) cd .. @@ -21,7 +21,7 @@ TEST=$(find ./tests/headers -type f -iname "*$1*" | head -n 1) BINDINGS=$(mktemp -t bindings.rs.XXXXXX) TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXXX) -FLAGS="$(grep "// bindgen-flags: " "$TEST")" +FLAGS="$(grep "// bindgen-flags: " "$TEST" || echo)" FLAGS="${FLAGS/\/\/ bindgen\-flags:/}" eval ./target/debug/bindgen \ @@ -34,14 +34,36 @@ eval ./target/debug/bindgen \ dot -Tpng ir.dot -o ir.png +echo echo "=== Input header ========================================================" +echo + cat "$TEST" +echo echo "=== Generated bindings ==================================================" +echo + cat "$BINDINGS" +echo +echo "=== Diff w/ expected bindings ===========================================" +echo + +EXPECTED=${TEST/headers/expectations\/tests} +EXPECTED=${EXPECTED/.hpp/.rs} + +# Don't exit early if there is a diff. +diff -U8 "$EXPECTED" "$BINDINGS" || true + +echo echo "=== Building bindings ===================================================" +echo + rustc --test -o "$TEST_BINDINGS_BINARY" "$BINDINGS" --crate-name bindgen_test_one +echo echo "=== Testing bindings ====================================================" +echo + "$TEST_BINDINGS_BINARY" |