From a9558acec0bcd6d66010c08f4f811c8f12098539 Mon Sep 17 00:00:00 2001 From: Thomas Levine Date: Thu, 11 Oct 2012 14:50:03 -0400 Subject: [PATCH] fullpath --- .../.chainsaw/successful test | 0 .../.test/successful test | 0 .../no molly guard if named test | 0 tests/flags/{filepath => filename}/override | 0 .../{filepath => filename}/warn on non-test | 0 .../filepath/no molly guard if test in path | 3 --- urchin | 25 +++++++++++-------- 7 files changed, 14 insertions(+), 14 deletions(-) rename tests/flags/{filepath => filename}/.chainsaw/successful test (100%) rename tests/flags/{filepath => filename}/.test/successful test (100%) rename tests/flags/{filepath => filename}/no molly guard if named test (100%) rename tests/flags/{filepath => filename}/override (100%) rename tests/flags/{filepath => filename}/warn on non-test (100%) delete mode 100755 tests/flags/filepath/no molly guard if test in path diff --git a/tests/flags/filepath/.chainsaw/successful test b/tests/flags/filename/.chainsaw/successful test similarity index 100% rename from tests/flags/filepath/.chainsaw/successful test rename to tests/flags/filename/.chainsaw/successful test diff --git a/tests/flags/filepath/.test/successful test b/tests/flags/filename/.test/successful test similarity index 100% rename from tests/flags/filepath/.test/successful test rename to tests/flags/filename/.test/successful test diff --git a/tests/flags/filepath/no molly guard if named test b/tests/flags/filename/no molly guard if named test similarity index 100% rename from tests/flags/filepath/no molly guard if named test rename to tests/flags/filename/no molly guard if named test diff --git a/tests/flags/filepath/override b/tests/flags/filename/override similarity index 100% rename from tests/flags/filepath/override rename to tests/flags/filename/override diff --git a/tests/flags/filepath/warn on non-test b/tests/flags/filename/warn on non-test similarity index 100% rename from tests/flags/filepath/warn on non-test rename to tests/flags/filename/warn on non-test diff --git a/tests/flags/filepath/no molly guard if test in path b/tests/flags/filepath/no molly guard if test in path deleted file mode 100755 index 513203e..0000000 --- a/tests/flags/filepath/no molly guard if test in path +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -../../../urchin .foo diff --git a/urchin b/urchin index 65d2d49..3dc3c42 100755 --- a/urchin +++ b/urchin @@ -1,5 +1,12 @@ #!/bin/bash +fullpath() { + ( + cd "$1" + pwd + ) +} + indent() { level="$1" printf "%$((2 * ${level}))s" @@ -52,12 +59,12 @@ recurse() { # On success, print a '✓' echo -ne '\033[32m✓ \033[0m' echo "${potential_test}" - [ -z "$logfile" ] || echo "${potential_test} passed" >> "$logfile" + echo "${potential_test} passed" >> "$logfile" else # On fail, print a red '✗' echo -ne '\033[31m✗ \033[0m' echo "${potential_test}" - [ -z "$logfile" ] || echo "${potential_test} failed" >> "$logfile" + echo "${potential_test} failed" >> "$logfile" cat $stdout_file fi rm $stdout_file @@ -83,12 +90,12 @@ urchin_help() { urchin_go() { echo Running tests - [ -z "$logfile" ] || echo > "$logfile" + echo > "$logfile" recurse "$1" 0 echo Done - [ -z "$logfile" ] || echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed. - [ -z "$logfile" ] || echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed. + echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed. + echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed. } urchin_molly_guard() { @@ -118,8 +125,7 @@ do done # Constants -logfile=$(readlink -f "$1/.urchin.log") || - echo readlink -f is not supported, so some features are not available. 1>&2 +logfile=$(fullpath "$1")/.urchin.log stdout_file=/tmp/urchin_stdout # Help first @@ -129,11 +135,8 @@ $HELP && urchin_help [ "$#" = '1' ] && [ -d "$1" ] || ( echo "$USAGE" && exit 1 ) -# Expand the starting directory if readlink -f works. -startdir=$(readlink -f "$1" 2> /dev/null) || startdir="$1" - # Run or present the Molly guard. -if echo "$startdir" | grep test || $FORCE +if echo "$(basename "$(fullpath "$1")")" | grep test || $FORCE then urchin_go "$1" else