tide/dev/tide_test.fish

72 lines
1.7 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
2020-05-20 00:10:19 +03:00
printf '%s\n' "$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
2020-05-20 00:10:19 +03:00
printf '%s\n' '--------PASSED--------'
2020-05-10 01:38:07 +03:00
cat $passed
rm $passed
end
if test -e $failed
2020-05-20 00:10:19 +03:00
printf '%s\n' '--------FAILED--------'
2020-05-10 01:38:07 +03:00
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-20 20:39:44 +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-20 00:10:19 +03:00
printf '%s\n' 'Usage: '$g'tide_test '$n'[options] '$b'[TESTS...]'$n
printf '%s\n'
printf '%s\n' 'Options:'
printf '%s\n'
2020-05-10 01:38:07 +03:00
for option in $optionList
2020-05-20 00:10:19 +03:00
printf '%s' ' -'$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)
2020-05-20 00:10:19 +03:00
printf '%s\n' $descriptionList[$descriptionIndex]
2020-05-10 01:38:07 +03:00
end
2020-05-05 00:22:08 +03:00
end