refactoring
This commit is contained in:
parent
a97bb751bc
commit
3a4a7012a7
59
urchin
59
urchin
@ -209,15 +209,6 @@ md5 () {
|
||||
esac
|
||||
}
|
||||
|
||||
# -------------------- Temporary directory --------------------
|
||||
urchin_tmp=$(mktemp_dir)
|
||||
> "${urchin_tmp}/log"
|
||||
|
||||
urchin_exit() {
|
||||
rm -Rf "${urchin_tmp}"
|
||||
exit "$@"
|
||||
}
|
||||
|
||||
# -------------------- Utilities --------------------
|
||||
epoch_date() {
|
||||
date +%s
|
||||
@ -251,15 +242,6 @@ indent() {
|
||||
fi
|
||||
}
|
||||
|
||||
stdout_file() {
|
||||
the_test="${1}"
|
||||
the_shell="${2}"
|
||||
|
||||
x="${urchin_tmp}/stdout$(fullpath "$the_test")"
|
||||
mkdir -p "${x}"
|
||||
echo "${x}/$(md5 "${the_shell}")"
|
||||
}
|
||||
|
||||
# Expand relative paths
|
||||
fullpath() {
|
||||
readlink -f -- "${1}"
|
||||
@ -284,8 +266,20 @@ remove_trailing_slash() {
|
||||
echo "$1" | sed s/\\/$//
|
||||
}
|
||||
|
||||
# Find the root directory of the present test suite
|
||||
urchin_root() {
|
||||
# File where a test's stdout and stderr is saved
|
||||
stdout_file() {
|
||||
tmp_dir="${1}"
|
||||
the_test="${2}"
|
||||
the_shell="${3}"
|
||||
|
||||
x="${tmp_dir}/stdout$(fullpath "$the_test")"
|
||||
mkdir -p "${x}"
|
||||
echo "${x}/$(md5 "${the_shell}")"
|
||||
}
|
||||
|
||||
# Root directory of the present test suite
|
||||
# USAGE: test_suite_root <directory>
|
||||
test_suite_root() {
|
||||
# Call recursively but remember the original argument.
|
||||
orig="${2:-$1}"
|
||||
current="${1%/}"
|
||||
@ -303,11 +297,11 @@ urchin_root() {
|
||||
echo "${current}: No such file or directory">&2
|
||||
return 1
|
||||
elif test -f "${current}"; then
|
||||
urchin_root "$(dirname -- "${current}")" "${orig}"
|
||||
test_suite_root "$(dirname -- "${current}")" "${orig}"
|
||||
elif test -f "${current}"/.urchin_root; then
|
||||
echo "${current}"
|
||||
else
|
||||
urchin_root "${current}"/.. "${orig}"
|
||||
test_suite_root "${current}"/.. "${orig}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -329,7 +323,7 @@ format_tap() {
|
||||
|
||||
print_stdout() {
|
||||
echo '# ------------ Begin output ------------'
|
||||
sed 's/^/# /' "$(stdout_file "${path}" "${the_shell}")"
|
||||
sed 's/^/# /' "$(stdout_file "${tmp_dir}" "${path}" "${the_shell}")"
|
||||
echo '# ------------ End output ------------'
|
||||
}
|
||||
|
||||
@ -382,11 +376,11 @@ format_urchin() {
|
||||
}
|
||||
|
||||
print_stdout() {
|
||||
sed 's/^/ | /' "$(stdout_file "${path}" "${the_shell}")"
|
||||
sed 's/^/ | /' "$(stdout_file "${tmp_dir}" "${path}" "${the_shell}")"
|
||||
}
|
||||
|
||||
while IFS="${HT}" read remote the_shell path result file_elapsed; do
|
||||
abspath=${urchin_tmp}/${path}
|
||||
abspath=${tmp_dir}/${path}
|
||||
|
||||
currentdir="$(dirname -- "${path}")"
|
||||
prevdir="${currentdir}"
|
||||
@ -433,6 +427,15 @@ format_urchin() {
|
||||
fi
|
||||
}
|
||||
|
||||
# XXX
|
||||
urchin_tmp=$(mktemp_dir)
|
||||
> "${urchin_tmp}/log"
|
||||
|
||||
urchin_exit() {
|
||||
rm -Rf "${urchin_tmp}"
|
||||
exit "$@"
|
||||
}
|
||||
|
||||
# -------------------- Main stuff --------------------
|
||||
recurse() {
|
||||
requested_path="${1}"
|
||||
@ -440,7 +443,7 @@ recurse() {
|
||||
cycle_shell="${3}"
|
||||
TEST_SHELL="${4}"
|
||||
|
||||
root="$(urchin_root "${1}")"
|
||||
root="$(test_suite_root "${1}")"
|
||||
|
||||
for ignore in setup_dir teardown_dir setup teardown; do
|
||||
if test "$(basename "${potential_test}")" = "${ignore}"; then
|
||||
@ -534,7 +537,7 @@ recurse() {
|
||||
TEST_SHELL=/bin/sh $TIMEOUT "${potential_test}"
|
||||
fi
|
||||
fi
|
||||
} > "$(stdout_file "${potential_test}" "${the_test_shell}")" 2>&1
|
||||
} > "$(stdout_file "${tmp_dir}" "${potential_test}" "${the_test_shell}")" 2>&1
|
||||
exit_code="${?}"
|
||||
set -e
|
||||
finish=$("${epoch}")
|
||||
@ -663,7 +666,7 @@ you don't need to quote the TEST_SHELL variable." >&2
|
||||
urchin_exit 11
|
||||
elif ! {
|
||||
# Molly guard
|
||||
root="$(urchin_root "${1}")"
|
||||
root="$(test_suite_root "${1}")"
|
||||
basename "$(fullpath "${root}")" |
|
||||
grep -i 'test' > /dev/null || "${force}"
|
||||
}; then
|
||||
|
Loading…
Reference in New Issue
Block a user