mirror of
https://github.com/apache/httpd.git
synced 2026-10-23 22:49:01 +03:00
helper for interactive individual tests
accepts filesystem path or the path as printed out when running all tests git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1938647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
63
test/run-one-test.sh
Executable file
63
test/run-one-test.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run-one-test.sh -- re-run a single test (file, directory or ::nodeid) via
|
||||
# run-all-tests.sh, picking the right suite from the path.
|
||||
#
|
||||
# Usage:
|
||||
# ./run-one-test.sh PATH[::nodeid] [pytest args...]
|
||||
#
|
||||
# PATH may be given as printed in the run-all-tests.sh output, or as a real
|
||||
# filesystem path from anywhere, e.g.:
|
||||
# ./run-one-test.sh tests/t/apache/test_404.py # pytest_suite
|
||||
# ./run-one-test.sh tests/t/apache/test_404.py::test_x -v
|
||||
# ./run-one-test.sh modules/http2/test_003_get.py # pyhttpd
|
||||
# ./run-one-test.sh test/modules/http2/test_003_get.py
|
||||
#
|
||||
set -eu
|
||||
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
sed -n '3,14p' "$0" | sed 's/^# \{0,1\}//'
|
||||
exit 2
|
||||
fi
|
||||
|
||||
arg="$1"; shift
|
||||
file="${arg%%::*}"
|
||||
node=""
|
||||
[ "$file" != "$arg" ] && node="::${arg#*::}"
|
||||
|
||||
# Absolute path of an existing file or directory.
|
||||
abspath() {
|
||||
d=$(cd "$(dirname "$1")" 2>/dev/null && pwd) || return 1
|
||||
echo "$d/$(basename "$1")"
|
||||
}
|
||||
|
||||
# Try the path as given, then relative to each suite's root (how the test
|
||||
# output prints them), then relative to the source tree root (test/...).
|
||||
abs=""
|
||||
for cand in "$file" "$here/pytest_suite/$file" "$here/$file" \
|
||||
"$(dirname "$here")/$file"; do
|
||||
if [ -e "$cand" ]; then abs=$(abspath "$cand"); break; fi
|
||||
done
|
||||
if [ -z "$abs" ]; then
|
||||
echo "run-one-test.sh: no such test path: $file" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
case "$abs" in
|
||||
"$here/pytest_suite/"*)
|
||||
exec "$here/run-all-tests.sh" --only=pysuite "$@" \
|
||||
"${abs#"$here/pytest_suite/"}$node"
|
||||
;;
|
||||
"$here/modules/"*)
|
||||
# pyhttpd paths are taken from PYHTTPD_TARGETS, relative to test/.
|
||||
PYHTTPD_TARGETS="${abs#"$here/"}$node"
|
||||
export PYHTTPD_TARGETS
|
||||
exec "$here/run-all-tests.sh" --only=pyhttpd "$@"
|
||||
;;
|
||||
*)
|
||||
echo "run-one-test.sh: $abs is not under pytest_suite/ or modules/" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user