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