1
0
Fork 0
mirror of synced 2024-12-22 06:01:07 -05:00

Add --debug flag to test driver

This is easier than the old method of adding `DEBUG=true` to the top of
test files.
This commit is contained in:
Anish Athalye 2021-02-25 08:14:34 -05:00
parent 43b62ed532
commit dac7a9bc88
4 changed files with 22 additions and 6 deletions

View file

@ -51,8 +51,8 @@ edits on your host machine). You can run the test suite by `cd /dotbot/test`
and then running `./test`. Selected tests can be run by passing paths to the
tests as arguments, e.g. `./test tests/create.bash tests/defaults.bash`.
To debug tests, you can prepend the line `DEBUG=true` as the first line to any
individual test (a `.bash` file inside `test/tests`). This will enable printing
To debug tests, you can run the test driver with the `--debug` (or `-d` short
form) flag, e.g. `./test --debug tests/link-if.bash`. This will enable printing
stdout/stderr.
When finished with testing, it is good to shut down the virtual machine by

View file

@ -60,7 +60,7 @@ run_test() {
tests_run=$((tests_run + 1))
printf '[%d/%d] (%s)\n' "${tests_run}" "${tests_total}" "${1}"
cleanup
if (cd "${BASEDIR}/test/tests" && HOME=~/fakehome DOTBOT_TEST=true bash "${1}"); then
if (cd "${BASEDIR}/test/tests" && HOME=~/fakehome DEBUG=${2} DOTBOT_TEST=true bash "${1}"); then
pass
else
fail

View file

@ -10,6 +10,23 @@ start="$(date +%s)"
check_env
# parse flags; must come before positional arguments
POSITIONAL=()
DEBUG=false
while [[ $# -gt 0 ]]; do
case $1 in
-d|--debug)
DEBUG=true
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional arguments
declare -a tests=()
if [ $# -eq 0 ]; then
@ -20,10 +37,10 @@ else
tests=("$@")
fi
initialize "${#tests[@]}" "${VERSION}"
initialize "${#tests[@]}"
for file in "${tests[@]}"; do
run_test "$(basename "${file}")" "${VERSION}"
run_test "$(basename "${file}")" "${DEBUG}"
done
if report; then

View file

@ -1,4 +1,3 @@
DEBUG=${DEBUG:-false}
DOTBOT_EXEC="${BASEDIR}/bin/dotbot"
DOTFILES="${HOME}/dotfiles"
INSTALL_CONF='install.conf.yaml'