@@ -16,25 +16,65 @@ echo "TODO: foo"
1616EOF
1717chmod +x foo
1818
19+ cat > foo2 << 'EOF '
20+ shift
21+ IFS=- # Print arguments separated with dashes to recognize the individual arguments.
22+ printf 'TODO: %s\n' "$*"
23+ EOF
24+ chmod +x foo2
25+
1926test_expect_success ' custom action (default location 1)' '
20- mkdir .todo.actions.d
21- cp foo .todo.actions.d/
27+ mkdir -p .todo.actions.d && cp foo .todo.actions.d/
2228 todo.sh foo > output;
2329 test_cmp expect output && rm -rf .todo.actions.d
2430'
2531
2632test_expect_success ' custom action (default location 2)' '
27- mkdir -p .todo/actions
28- cp foo .todo/actions/
33+ mkdir -p .todo/actions && cp foo .todo/actions/
2934 todo.sh foo > output;
3035 test_cmp expect output && rm -rf .todo/actions
3136'
3237
3338test_expect_success ' custom action (env variable)' '
34- mkdir myactions
35- cp foo myactions/
39+ mkdir -p myactions && cp foo myactions/
3640 TODO_ACTIONS_DIR=myactions todo.sh foo > output;
3741 test_cmp expect output && rm -rf myactions
3842'
3943
44+ test_expect_success ' custom action (default action)' '
45+ mkdir -p .todo.actions.d && cp foo2 .todo.actions.d/
46+ TODOTXT_DEFAULT_ACTION="foo2 foo" todo.sh > output;
47+ test_cmp expect output && rm -rf .todo.actions.d
48+ '
49+
50+ test_todo_session ' default built-in action with multiple arguments' << EOF
51+ >>> TODOTXT_DEFAULT_ACTION='add +foo @bar baz' todo.sh
52+ 1 +foo @bar baz
53+ TODO: 1 added.
54+ EOF
55+
56+ test_todo_session ' default custom action with multiple arguments' << EOF
57+ >>> mkdir -p .todo.actions.d && cp foo2 .todo.actions.d/
58+
59+ >>> TODOTXT_DEFAULT_ACTION='foo2 foo bar baz' todo.sh
60+ TODO: foo-bar-baz
61+ EOF
62+
63+ : > todo.txt
64+ export TODOTXT_DEFAULT_ACTION=" add foo\\ bar \\\$ HOSTNAME O\\ 'Really\\ ? \\\" quoted\\\" "
65+ test_todo_session ' default built-in action with arguments that have special characters' << EOF
66+ >>> todo.sh
67+ 1 foo bar \$ HOSTNAME O'Really? "quoted"
68+ TODO: 1 added.
69+ EOF
70+
71+ : > todo.txt
72+ export TODOTXT_DEFAULT_ACTION=" foo2 foo\\ bar \\\$ HOSTNAME O\\ 'Really\\ ? \\\" quoted\\\" "
73+ test_todo_session ' default custom action with arguments that have special characters' << EOF
74+ >>> mkdir -p .todo.actions.d && cp foo2 .todo.actions.d/
75+
76+ >>> todo.sh
77+ TODO: foo bar-\$ HOSTNAME-O'Really?-"quoted"
78+ EOF
79+
4080test_done
0 commit comments