Skip to content

Commit

Permalink
add test for completion of recipes in subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbochi committed Aug 29, 2022
1 parent 5c6cccd commit 23d9a55
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/completions/just.bash
Expand Up @@ -36,36 +36,44 @@ test_just_is_accessible() {
exit_code='1'
fi
}
PATH="./target/debug:$PATH"
test_just_is_accessible

test_complete_all_recipes() {
COMP_WORDS=(just)
COMP_CWORD=1 _just just
reply_equals 'declare -a COMPREPLY=([0]="build" [1]="build-book" [2]="changes" [3]="check" [4]="ci" [5]="clippy" [6]="done" [7]="filter" [8]="fmt" [9]="forbid" [10]="fuzz" [11]="generate-completions" [12]="install" [13]="install-dev-deps" [14]="install-dev-deps-homebrew" [15]="man" [16]="polyglot" [17]="pr" [18]="publish" [19]="push" [20]="pwd" [21]="quine" [22]="render-readme" [23]="replace" [24]="run" [25]="sloc" [26]="test" [27]="test-quine" [28]="view-man" [29]="watch" [30]="watch-readme")'
}
cleanup
test_complete_all_recipes

test_complete_recipes_starting_with_i() {
COMP_WORDS=(just i)
COMP_CWORD=1 _just just
reply_equals 'declare -a COMPREPLY=([0]="install" [1]="install-dev-deps" [2]="install-dev-deps-homebrew")'
}
cleanup
test_complete_recipes_starting_with_i

test_complete_recipes_starting_with_r() {
COMP_WORDS=(just r)
COMP_CWORD=1 _just just
reply_equals 'declare -a COMPREPLY=([0]="render-readme" [1]="replace" [2]="run")'
}

PATH="./target/debug:$PATH"
test_just_is_accessible

cleanup
test_complete_all_recipes
test_complete_recipes_starting_with_r

test_complete_recipes_from_subdirs() {
mkdir -p ./tmp
echo 'install:' > tmp/justfile
echo 'deploy:' >> tmp/justfile
COMP_WORDS=(just tmp/)
COMP_CWORD=1 _just just
reply_equals 'declare -a COMPREPLY=([0]="tmp/deploy" [1]="tmp/install")'
}
cleanup
test_complete_recipes_starting_with_i

test_complete_recipes_from_subdirs
cleanup
test_complete_recipes_starting_with_r

if [ "$exit_code" = '0' ]; then
echo "All tests passed."
Expand Down

0 comments on commit 23d9a55

Please sign in to comment.