testcases
This commit is contained in:
@@ -1,20 +1,42 @@
|
|||||||
|
|
||||||
completion1() {
|
BAKE=$( readlink -f ../bake )
|
||||||
echo Args: "$@"
|
internals() {
|
||||||
|
_yecho "flines function"
|
||||||
|
_assert_eq "$( cd internals; $BAKE flines | wc -l )" "4"
|
||||||
|
_yecho "commands function"
|
||||||
|
_assert_eq "$( cd internals; $BAKE commands )" "^target1$|^target2$|^flines$|^commands$"
|
||||||
|
_yecho "Not a target should fail"
|
||||||
|
( cd internals; $BAKE non-existent ) && { _fail; } || { _pass; }
|
||||||
|
|
||||||
|
_yecho "Item help"
|
||||||
|
_assert_eq "$( cd internals; $BAKE -h target2 | tail -n1 )" $'\e[36mSub help\e[0m'
|
||||||
|
|
||||||
|
_yecho "Multiple targets"
|
||||||
|
_assert_eq "$( cd internals; $BAKE target1,target2 )" $'1\n2'
|
||||||
}
|
}
|
||||||
|
|
||||||
_complete_completion1() {
|
|
||||||
compgen -o plusdirs -f -- "$1"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_assert_eq() {
|
||||||
|
if [[ "$1" = "$2" ]]; then
|
||||||
|
_pass
|
||||||
|
else
|
||||||
|
echo Expect: "$2"
|
||||||
|
echo Received: "$1"
|
||||||
|
_fail
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
completion2() {
|
_fail() {
|
||||||
echo Hard coded choices: "$@"
|
_recho "Test failed"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
_pass() {
|
||||||
_complete_completion2() {
|
_gecho "Test Passed"
|
||||||
echo "choice1 alternative2"
|
|
||||||
}
|
|
||||||
|
|
||||||
nocompletion() {
|
|
||||||
echo Args: "$@"
|
|
||||||
}
|
}
|
||||||
|
_gecho() { printf '\e[1;32m%s\e[0m\n' "$1"; }
|
||||||
|
_recho() { printf '\e[1;31m%s\e[0m\n' "$1"; }
|
||||||
|
_yecho() { printf '\e[1;33m%s\e[0m\n' "$1"; }
|
||||||
|
|||||||
20
testing/completion/Bakefile
Normal file
20
testing/completion/Bakefile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
completion1() {
|
||||||
|
echo Args: "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_complete_completion1() {
|
||||||
|
compgen -o plusdirs -f -- "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
completion2() {
|
||||||
|
echo Hard coded choices: "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_complete_completion2() {
|
||||||
|
echo "choice1 alternative2"
|
||||||
|
}
|
||||||
|
|
||||||
|
nocompletion() {
|
||||||
|
echo Args: "$@"
|
||||||
|
}
|
||||||
17
testing/internals/Bakefile
Normal file
17
testing/internals/Bakefile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
target1() {
|
||||||
|
echo 1
|
||||||
|
}
|
||||||
|
target2() { # Target description
|
||||||
|
# Sub help
|
||||||
|
echo 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
flines() {
|
||||||
|
_flines
|
||||||
|
}
|
||||||
|
|
||||||
|
commands() {
|
||||||
|
_commands
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user