summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rwxr-xr-xtests/test-one.sh27
2 files changed, 28 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 71a7df6d..906dcfee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,7 @@ target/
bindgen-integration/Cargo.lock
tests/expectations/Cargo.lock
#*#
+
+# Test script output
+ir.dot
+ir.png
diff --git a/tests/test-one.sh b/tests/test-one.sh
index ac466164..d274a53f 100755
--- a/tests/test-one.sh
+++ b/tests/test-one.sh
@@ -10,13 +10,34 @@
set -eu
-cd $(dirname $0)
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 <fuzzy-name>"
+ exit 1
+fi
+
+cd "$(dirname "$0")"
cd ..
export RUST_BACKTRACE=1
-# Grab the first match
-TEST=$(find ./tests/headers -type f -iname "*$1*" | head -n 1)
+unique_fuzzy_file() {
+ local pattern="$1"
+ local results="$(find ./tests/headers -type f -iname "*$pattern*")"
+ local num_results=$(echo "$results" | wc -l)
+
+ if [[ -z "$results" ]]; then
+ >&2 echo "ERROR: no files found with pattern \"$pattern\""
+ exit 1
+ elif [[ "$num_results" -ne 1 ]]; then
+ >&2 echo "ERROR: Expected exactly 1 result, got $num_results:"
+ >&2 echo "$results"
+ exit 1
+ fi
+
+ echo "$results"
+}
+
+TEST="$(unique_fuzzy_file "$1")"
BINDINGS=$(mktemp -t bindings.rs.XXXXXX)
TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXXX)