forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify_examples.sh
executable file
·52 lines (44 loc) · 1.13 KB
/
verify_examples.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash -E
TESTFILTER="${1:-*}"
TESTEXCLUDES="${2}"
FAILED=()
SRCDIR="${SRCDIR:-$(pwd)}"
trap_errors () {
local frame=0 command line sub file
if [[ -n "$example" ]]; then
command=" (${example})"
fi
set +v
while read -r line sub file < <(caller "$frame"); do
if [[ "$frame" -ne "0" ]]; then
FAILED+=(" > ${sub}@ ${file} :${line}")
else
FAILED+=("${sub}@ ${file} :${line}${command}")
fi
((frame++))
done
set -v
}
trap trap_errors ERR
trap exit 1 INT
run_examples () {
local examples example
cd "${SRCDIR}/examples" || exit 1
examples=$(find . -mindepth 1 -maxdepth 1 -type d -name "$TESTFILTER" ! -iname "_*" | sort)
if [[ -n "$TESTEXCLUDES" ]]; then
examples=$(echo "$examples" | grep -Ev "$TESTEXCLUDES")
fi
for example in $examples; do
pushd "$example" > /dev/null || return 1
./verify.sh
popd > /dev/null || return 1
done
}
run_examples
if [[ "${#FAILED[@]}" -ne "0" ]]; then
echo "TESTS FAILED:"
for failed in "${FAILED[@]}"; do
echo "$failed" >&2
done
exit 1
fi