diff --git a/tests/t8010-listaddons.sh b/tests/t8010-listaddons.sh index b4e89aa9..779dafa0 100755 --- a/tests/t8010-listaddons.sh +++ b/tests/t8010-listaddons.sh @@ -9,12 +9,16 @@ This test checks listing of custom actions. test_todo_session 'no custom actions' <>> todo.sh listaddons +TODO: '$TODO_ACTIONS_DIR' does not exist. +=== 1 EOF make_action "foo" test_todo_session 'one custom action' <>> todo.sh listaddons foo +-- +TODO: 1 valid addon actions found. EOF make_action "bar" @@ -26,6 +30,8 @@ bar foo ls quux +-- +TODO: 4 valid addon actions found. EOF chmod -x .todo.actions.d/foo @@ -39,6 +45,8 @@ test_todo_session 'nonexecutable action' <&2 "$*" exit 1 } @@ -864,7 +865,7 @@ _list() { local FILE="$1" ## If the file starts with a "/" use absolute path. Otherwise, ## try to find it in either $TODO_DIR or using a relative path - if [ "${1:0:1}" == / ]; then + if [ "${1:0:1}" == / ] && [ -f "$FILE" ]; then ## Absolute path src="$FILE" elif [ -f "$TODO_DIR/$FILE" ]; then @@ -1485,14 +1486,27 @@ note: PRIORITY must be anywhere from A to Z." "listaddons" ) if [ -d "$TODO_ACTIONS_DIR" ]; then cd "$TODO_ACTIONS_DIR" || exit $? + actionsCnt=0 for action in * do if [ -f "$action" ] && [ -x "$action" ]; then echo "$action" + ((actionsCnt+=1)) elif [ -d "$action" ] && [ -x "$action/$action" ]; then echo "$action" + ((actionsCnt+=1)) fi done + if ! [ "$actionsCnt" -gt 0 ]; then + die "TODO: '$TODO_ACTIONS_DIR' does not contain valid actions." + else + if [ "$TODOTXT_VERBOSE" -gt 0 ]; then + echo "--" + echo "TODO: $actionsCnt valid addon actions found." + fi + fi + else + die "TODO: '$TODO_ACTIONS_DIR' does not exist." fi ;;