Skip to content

Commit a909b96

Browse files
committed
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.
1 parent 2588683 commit a909b96

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tests/test-one.sh

+24-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# `rustc` to compile the bindings with unit tests enabled, and run the generated
99
# layout tests.
1010

11-
set -eux
11+
set -eu
1212

1313
cd $(dirname $0)
1414
cd ..
@@ -21,7 +21,7 @@ TEST=$(find ./tests/headers -type f -iname "*$1*" | head -n 1)
2121
BINDINGS=$(mktemp -t bindings.rs.XXXXXX)
2222
TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXXX)
2323

24-
FLAGS="$(grep "// bindgen-flags: " "$TEST")"
24+
FLAGS="$(grep "// bindgen-flags: " "$TEST" || echo)"
2525
FLAGS="${FLAGS/\/\/ bindgen\-flags:/}"
2626

2727
eval ./target/debug/bindgen \
@@ -34,14 +34,36 @@ eval ./target/debug/bindgen \
3434

3535
dot -Tpng ir.dot -o ir.png
3636

37+
echo
3738
echo "=== Input header ========================================================"
39+
echo
40+
3841
cat "$TEST"
3942

43+
echo
4044
echo "=== Generated bindings =================================================="
45+
echo
46+
4147
cat "$BINDINGS"
4248

49+
echo
50+
echo "=== Diff w/ expected bindings ==========================================="
51+
echo
52+
53+
EXPECTED=${TEST/headers/expectations\/tests}
54+
EXPECTED=${EXPECTED/.hpp/.rs}
55+
56+
# Don't exit early if there is a diff.
57+
diff -U8 "$EXPECTED" "$BINDINGS" || true
58+
59+
echo
4360
echo "=== Building bindings ==================================================="
61+
echo
62+
4463
rustc --test -o "$TEST_BINDINGS_BINARY" "$BINDINGS" --crate-name bindgen_test_one
4564

65+
echo
4666
echo "=== Testing bindings ===================================================="
67+
echo
68+
4769
"$TEST_BINDINGS_BINARY"

0 commit comments

Comments
 (0)