summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-06-19 09:15:54 -0700
committerGitHub <noreply@github.com>2017-06-19 09:15:54 -0700
commitb08b59a7d03a5b9b408f19c18efc38134d6ff119 (patch)
tree8318fcd4e4522771da9ff7056eb544a4ff4e80d1
parentd37fe132be5350ed1477b4e578a5d1b70c583666 (diff)
parente7009e275155bb7989b0291625b7dd82edd7d80f (diff)
Auto merge of #761 - tmfink:script-fix, r=fitzgen
Refactor test script Check for correct arguments, quote variables, ensure exactly one test file matches the pattern, and print usage information. Here are some examples: ~~~ $ ./tests/test-one.sh Usage: ./tests/test-one.sh <fuzzy-name> ~~~ ~~~ $ ./tests/test-one.sh zzz ERROR: no files found with pattern "zzz" ~~~ ~~~ $ ./tests/test-one.sh union ERROR: Expected exactly 1 result, got 15: ./tests/headers/struct_with_anon_unnamed_union.h ./tests/headers/union_dtor.hpp ./tests/headers/union_with_anon_union.h ./tests/headers/union_with_big_member.h ./tests/headers/anon_union.hpp ./tests/headers/union_fields.hpp ./tests/headers/union_with_anon_struct_bitfield.h ./tests/headers/struct_with_anon_union.h ./tests/headers/union-in-ns.hpp ./tests/headers/union_with_anon_unnamed_union.h ./tests/headers/union_with_anon_struct.h ./tests/headers/union_with_nesting.h ./tests/headers/union_template.hpp ./tests/headers/anon_struct_in_union.h ./tests/headers/union_with_anon_unnamed_struct.h ~~~ ~~~ $ ./tests/test-one.sh keywords ... ~~~
-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)