Before adding any more features to todo_completion, I feel like I need test coverage, so this is a first stab at testing the completion results, via a new test function test_todo_completion. Some basic tests showcase the capabilities. Note: test-lib.sh now uses arrays, therefore all tests must use /bin/bash, not /bin/sh to avoid errors when sourcing test-lib. For consistency with todo.sh, we should have used Bash everywhere, anyway. Also note that t2000-multiline.sh needs some more quoting to avoid "Bash: ambiguous redirect" errors.
82 lines
1.7 KiB
Bash
Executable File
82 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
|
|
test_description='listproj functionality
|
|
|
|
This test checks basic project listing functionality
|
|
'
|
|
. ./test-lib.sh
|
|
|
|
cat > todo.txt <<EOF
|
|
item 1
|
|
item 2
|
|
item 3
|
|
EOF
|
|
test_expect_success 'listproj no projects' '
|
|
todo.sh listproj > output && ! test -s output
|
|
'
|
|
|
|
cat > todo.txt <<EOF
|
|
(A) +1 -- Some project 1 task, whitespace, one char
|
|
(A) +p2 -- Some project 2 task, whitespace, two char
|
|
+prj03 -- Some project 3 task, no whitespace
|
|
+prj04 -- Some project 4 task, no whitespace
|
|
+prj05+prj06 -- weird project
|
|
EOF
|
|
test_todo_session 'Single project per line' <<EOF
|
|
>>> todo.sh listproj
|
|
+1
|
|
+p2
|
|
+prj03
|
|
+prj04
|
|
+prj05+prj06
|
|
EOF
|
|
|
|
cat > todo.txt <<EOF
|
|
+prj01 -- Some project 1 task
|
|
+prj02 -- Some project 2 task
|
|
+prj02 +prj03 -- Multi-project task
|
|
EOF
|
|
test_todo_session 'Multi-project per line' <<EOF
|
|
>>> todo.sh listproj
|
|
+prj01
|
|
+prj02
|
|
+prj03
|
|
EOF
|
|
|
|
cat > todo.txt <<EOF
|
|
+prj01 -- Some project 1 task
|
|
+prj02 -- Some project 2 task
|
|
+prj02 ginatrapani+todo@gmail.com -- Some project 2 task
|
|
EOF
|
|
test_todo_session 'listproj embedded + test' <<EOF
|
|
>>> todo.sh listproj
|
|
+prj01
|
|
+prj02
|
|
EOF
|
|
|
|
cat > todo.txt <<EOF
|
|
+prj01 -- Some project 1 task
|
|
EOF
|
|
cat > done.txt <<EOF
|
|
x 2012-02-21 +done01 -- Special project 1 done task
|
|
x 2012-02-21 +done02 -- Some project 2 done task
|
|
EOF
|
|
test_todo_session 'listproj from done tasks' <<'EOF'
|
|
>>> TODOTXT_SOURCEVAR=\$DONE_FILE todo.sh listproj
|
|
+done01
|
|
+done02
|
|
EOF
|
|
test_todo_session 'listproj from done tasks with filtering' <<'EOF'
|
|
>>> TODOTXT_SOURCEVAR=\$DONE_FILE todo.sh listproj Special
|
|
+done01
|
|
EOF
|
|
test_todo_session 'listproj from combined open + done tasks' <<'EOF'
|
|
>>> TODOTXT_SOURCEVAR='("$TODO_FILE" "$DONE_FILE")' todo.sh listproj
|
|
+done01
|
|
+done02
|
|
+prj01
|
|
EOF
|
|
|
|
test_done
|