Make e2e treat args as tests-name regexes
This commit is contained in:
parent
ad3955c0fa
commit
5707870ecc
46
test_e2e.sh
46
test_e2e.sh
|
|
@ -1827,35 +1827,53 @@ function list_tests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Figure out which, if any, tests to run.
|
# Figure out which, if any, tests to run.
|
||||||
tests=($(list_tests))
|
all_tests=($(list_tests))
|
||||||
|
tests_to_run=()
|
||||||
|
|
||||||
function print_tests() {
|
function print_tests() {
|
||||||
echo "available tests:"
|
echo "available tests:"
|
||||||
for t in "${tests[@]}"; do
|
for t in "${all_tests[@]}"; do
|
||||||
echo " $t"
|
echo " $t"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
for t; do
|
# Validate and accumulate tests to run if args are specified.
|
||||||
|
for arg; do
|
||||||
# Use -? to list known tests.
|
# Use -? to list known tests.
|
||||||
if [[ "${t}" == "-?" ]]; then
|
if [[ "${arg}" == "-?" ]]; then
|
||||||
print_tests
|
print_tests
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
# Make sure we know this test.
|
if [[ "${arg}" =~ ^- ]]; then
|
||||||
if [[ " ${tests[*]} " =~ " ${t} " ]]; then
|
echo "ERROR: unknown flag '${arg}'"
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Not a known test or flag.
|
# Make sure each non-flag arg matches at least one test.
|
||||||
echo "ERROR: unknown test or flag: '${t}'"
|
nmatches=0
|
||||||
echo
|
for t in "${all_tests[@]}"; do
|
||||||
print_tests
|
if [[ "${t}" =~ ${arg} ]]; then
|
||||||
exit 1
|
nmatches=$((nmatches+1))
|
||||||
|
# Don't run tests twice, just keep the first match.
|
||||||
|
if [[ " ${tests_to_run[*]} " =~ " ${t} " ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
tests_to_run+=("${t}")
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ${nmatches} == 0 ]]; then
|
||||||
|
echo "ERROR: no tests match pattern '${arg}'"
|
||||||
|
echo
|
||||||
|
print_tests
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tests_to_run+=("${matches[@]}")
|
||||||
done
|
done
|
||||||
|
set -- "${tests_to_run[@]}"
|
||||||
|
|
||||||
# If no tests specified, run them all.
|
# If no tests were specified, run them all.
|
||||||
if [[ "$#" == 0 ]]; then
|
if [[ "$#" == 0 ]]; then
|
||||||
set -- "${tests[@]}"
|
set -- "${all_tests[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build it
|
# Build it
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue