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.
This commit is contained in:
Ingo Karkat
2011-01-20 15:07:47 +01:00
parent 2df5f9fee9
commit 819a8285cc

View File

@@ -8,10 +8,22 @@ This test covers the contract between todo.sh and custom actions.
unset TODO_ACTIONS_DIR unset TODO_ACTIONS_DIR
mkdir .todo.actions.d mkdir .todo.actions.d
cat > .todo.actions.d/foo << EOF make_action()
echo "TODO: foo" {
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' <<EOF
>>> todo.sh foo
custom action foo
EOF EOF
chmod -x .todo.actions.d/foo
test_todo_session 'nonexecutable action' <<EOF test_todo_session 'nonexecutable action' <<EOF
>>> todo.sh foo >>> todo.sh foo
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description] Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
@@ -19,33 +31,21 @@ Try 'todo.sh -h' for more information.
=== 1 === 1
EOF EOF
chmod +x .todo.actions.d/foo make_action "ls"
test_todo_session 'executable action' <<EOF
>>> todo.sh foo
TODO: foo
EOF
cat > .todo.actions.d/ls << EOF
echo "TODO: my ls"
EOF
chmod +x .todo.actions.d/ls
test_todo_session 'overriding built-in action' <<EOF test_todo_session 'overriding built-in action' <<EOF
>>> todo.sh ls >>> todo.sh ls
TODO: my ls custom action ls
>>> todo.sh command ls >>> todo.sh command ls
-- --
TODO: 0 of 0 tasks shown TODO: 0 of 0 tasks shown
EOF EOF
cat > .todo.actions.d/bad << EOF make_action "bad"
echo "TODO: bad" echo "exit 42" >> .todo.actions.d/bad
exit 42
EOF
chmod +x .todo.actions.d/bad
test_todo_session 'failing action' <<EOF test_todo_session 'failing action' <<EOF
>>> todo.sh bad >>> todo.sh bad
TODO: bad custom action bad
=== 42 === 42
EOF EOF