From dc90ed85780baff2863129ffb7b1265d92d868dc Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Mon, 11 Apr 2016 04:48:26 +0000 Subject: [PATCH] merge small functions --- urchin | 69 ++++++++++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/urchin b/urchin index bc256cd..0b0d399 100755 --- a/urchin +++ b/urchin @@ -161,20 +161,13 @@ EOF mktemp_dir() { # Support HP-UX mktemp that has wrong exit codes and # can't make directories. - tmp=$(mktemp /tmp/urchin.XXXXXXXX) + tmp=$(mktemp) if test -f "${tmp}"; then rm "${tmp}" fi mkdir "${tmp}" echo "${tmp}" } -mktemp_file() { - tmp=$(mktemp /tmp/urchin.XXXXXXXX) - if ! test -f "${tmp}"; then - > "${tmp}" - fi - echo "${tmp}" -} md5 () { case "${urchin_md5}" in @@ -198,7 +191,7 @@ epoch_date() { } epoch_pax() { # Based on http://stackoverflow.com/a/7262588/407226 - tmp="$(mktemp_file)" + tmp="$(mktemp)" echo "ibase=8;$({ pax -wx cpio "${tmp}"; echo; } | cut -c 48-59)" | bc rm "${tmp}" } @@ -563,33 +556,15 @@ recurse() { done wait fi - else + elif test -n "${rel_current}"; then # Skip because the file is not executable. echo "${shell_list}" | while read -r sh; do printf "\t${sh}\t${rel_current}\tskip\t0\n" >> "${urchin_tmp}"/log done fi + echo ${rel_current} 3 >> /tmp/bbb } -report_outcome() { - format="${2}" - log_file="${3}" - start="${4}" - finish="${5}" - - elapsed=$(($finish - $start)) - - # Use a temporary file rather than a pipe because a pipe starts a sub-shell - # and thus makes the above variables local. - sorted_log_file=$(mktemp_file) - cat "${log_file}" | LC_COLLATE=C sort > "${sorted_log_file}" - - rm "${sorted_log_file}" - - test "${not_oks}" -eq '0' -} - - main() { # Defaults format=urchin @@ -663,19 +638,23 @@ you don't need to quote the TEST_SHELL variable." >&2 # Molly guard root="$(test_suite_root "${1}")" basename "$(fullpath "${root}")" | - grep -i 'test' > /dev/null || "${force}" + grep -i 'test' > /dev/null }; then - echo 'The root directory of the tests that you are running urchin on -doesnot contain the word "test", so I am not running, -in case that was an accident. Use the -f flag if you really -wantto run urchin on that directory.' >&2 - exit 12 + molly=true fi test_seeds="${1}${LF}${test_seeds}" ;; esac shift done + if is_set molly && ! is_set force; then + echo 'The root directory of the tests that you are running urchin on +doesnot contain the word "test", so I am not running, +in case that was an accident. Use the -f flag if you really +want to run urchin on that directory.' >&2 + exit 12 + fi + # If -s was not passed, use the available default shells. if ! is_set "${shell_list}"; then if $cycle_shell; then @@ -722,16 +701,26 @@ wantto run urchin on that directory.' >&2 done< "${sorted_log_file}" + +# rm "${sorted_log_file}" + +# test "${not_oks}" -eq '0' + + else echo 'No tests found' >&2 return_code=2