From 819a8285cc95dc4972a6e6b3c8c98a3a59f30a6b Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Thu, 20 Jan 2011 15:07:47 +0100 Subject: [PATCH] Factored out generation of custom action scripts. - Reduced duplication via common make_action() function. - ENH: Adding proper shebang line to the custom action scripts. - Changed output of custom action to better differentiate from todo.sh output. --- tests/t8000-actions.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/t8000-actions.sh b/tests/t8000-actions.sh index 3d92248..91e3f19 100755 --- a/tests/t8000-actions.sh +++ b/tests/t8000-actions.sh @@ -8,10 +8,22 @@ This test covers the contract between todo.sh and custom actions. unset TODO_ACTIONS_DIR mkdir .todo.actions.d -cat > .todo.actions.d/foo << EOF -echo "TODO: foo" +make_action() +{ + cat > ".todo.actions.d/$1" <<- EOF + #!/bin/bash + echo "custom action $1" +EOF +chmod +x ".todo.actions.d/$1" +} + +make_action "foo" +test_todo_session 'executable action' <>> todo.sh foo +custom action foo EOF +chmod -x .todo.actions.d/foo test_todo_session 'nonexecutable action' <>> todo.sh foo Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description] @@ -19,33 +31,21 @@ Try 'todo.sh -h' for more information. === 1 EOF -chmod +x .todo.actions.d/foo -test_todo_session 'executable action' <>> todo.sh foo -TODO: foo -EOF - -cat > .todo.actions.d/ls << EOF -echo "TODO: my ls" -EOF -chmod +x .todo.actions.d/ls +make_action "ls" test_todo_session 'overriding built-in action' <>> todo.sh ls -TODO: my ls +custom action ls >>> todo.sh command ls -- TODO: 0 of 0 tasks shown EOF -cat > .todo.actions.d/bad << EOF -echo "TODO: bad" -exit 42 -EOF -chmod +x .todo.actions.d/bad +make_action "bad" +echo "exit 42" >> .todo.actions.d/bad test_todo_session 'failing action' <>> todo.sh bad -TODO: bad +custom action bad === 42 EOF