tide/dev/tide_test.fish

72 lines
1.6 KiB
Fish
Raw Normal View History

2020-05-19 06:03:25 +03:00
function tide_test
2020-05-10 01:38:07 +03:00
argparse 'h/help' 'v/verbose' 'a/all' -- $argv
if set -q _flag_help
_help
return 0
2020-05-05 00:22:08 +03:00
end
2020-05-10 01:38:07 +03:00
set -l testsDir "$__fish_config_dir/tests"
2020-05-06 19:42:52 +03:00
2020-05-19 06:03:25 +03:00
set -l pending '/tmp/tide_test'
set -l failed '/tmp/tide_test_failed'
set -l passed '/tmp/tide_test_passed'
2020-05-10 01:38:07 +03:00
if set -q _flag_all
set argv (basename -s '.fish' $testsDir/*)
end
for test in $argv
fishtape "$testsDir/$test.fish" >$pending
if test $status -eq 0
if set -q _flag_verbose
cat $pending >>$passed
else
echo "$test - ✔" >>$passed
2020-05-10 01:38:07 +03:00
end
else
cat $pending >>$failed
end
2020-05-06 19:42:52 +03:00
end
2020-05-10 01:38:07 +03:00
if test -e $passed
echo '--------PASSED--------'
cat $passed
rm $passed
end
if test -e $failed
echo '--------FAILED--------'
cat $failed
rm $failed
end
if test -e $pending
rm $pending
end
end
function _help
set -l b (set_color -o)
set -l n (set_color normal)
2020-05-19 06:03:25 +03:00
set -l g (set_color $tide_color_green)
2020-05-10 01:38:07 +03:00
set -l optionList \
'v or --verbose' \
'a or --all' \
'h or --help'
set -l descriptionList \
'display test output even if passed' \
'run all available tests' \
'print this help message'
2020-05-19 06:03:25 +03:00
echo 'Usage: '$g'tide_test '$n'[options] '$b'[TESTS...]'$n
2020-05-10 01:38:07 +03:00
echo
echo 'Options:'
echo
for option in $optionList
echo -n ' -'$option
2020-05-17 07:55:51 +03:00
_cursor_right 20
2020-05-10 01:38:07 +03:00
set -l descriptionIndex (contains -i $option $optionList)
echo $descriptionList[$descriptionIndex]
end
2020-05-05 00:22:08 +03:00
end