File: t6080-completion-path.sh

package info (click to toggle)
todotxt-cli 2.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,312 kB
  • sloc: sh: 5,393; makefile: 67
file content (45 lines) | stat: -rwxr-xr-x 1,175 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#

test_description='Bash completion with different path functionality

This test checks that todo_completion can use a different path to todo-txt when
it is not accessible through PATH.
'
. ./test-lib.sh

cat > todo.txt <<EOF
(B) smell the +roses @outside @outdoor +shared
notice the sunflowers +sunflowers @outside @garden +shared +landscape
stop
EOF

mv bin/todo-txt bin/todo2.sh
test_expect_success 'todo2.sh executable' 'todo2.sh list'

# Define a second completion function that injects the different executable. In
# real use, this would be installed via
#   complete -F _todo2 todo2.sh
_todo2()
{
    local _todo_sh='todo2.sh'
    _todo "$@"
}

test_todo_custom_completion _todo2 'all todo2 contexts' 'todo2 list @' '@garden @outdoor @outside'



# Remove the test environment's bin directory from the PATH, so that our test
# executable must be launched with an explicit path.
PATH=${PATH##"${PWD}/bin:"}
test_expect_code 127 'todo2.sh executable not in PATH' 'todo2.sh'

_todo2path()
{
    local _todo_sh='./bin/todo2.sh'
    _todo "$@"
}
test_todo_custom_completion _todo2path 'all todo2 contexts' 'todo2 list @' '@garden @outdoor @outside'

test_done