2014-10-03 03:31:46 +08:00
|
|
|
# Fishscript tests
|
2016-02-07 10:08:22 +08:00
|
|
|
#
|
|
|
|
# There is no shebang line because you shouldn't be running this by hand. You
|
|
|
|
# should be running it via `make test` to ensure the environment is properly
|
|
|
|
# setup.
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2017-01-29 12:37:32 +08:00
|
|
|
# Set this var to modify behavior of the code being tests. Such as avoiding running
|
|
|
|
# `fish_update_completions` when running tests.
|
|
|
|
set -x FISH_UNIT_TESTS_RUNNING 1
|
|
|
|
|
2014-12-24 04:20:44 +08:00
|
|
|
# Change to directory containing this script
|
2020-06-15 01:11:57 +08:00
|
|
|
cd (status dirname)
|
2014-12-24 04:20:44 +08:00
|
|
|
|
2020-03-29 01:29:21 +08:00
|
|
|
# Test files specified on commandline, or all checks.
|
2020-05-15 13:56:06 +08:00
|
|
|
set -l files_to_test
|
2014-12-24 04:20:44 +08:00
|
|
|
if set -q argv[1]
|
2020-03-29 01:29:21 +08:00
|
|
|
set files_to_test checks/$argv.fish
|
2014-12-24 04:20:44 +08:00
|
|
|
else
|
2020-03-18 04:24:37 +08:00
|
|
|
set files_to_test checks/*.fish
|
2014-12-24 04:20:44 +08:00
|
|
|
end
|
|
|
|
|
2020-11-15 01:55:56 +08:00
|
|
|
# test_util handles the environment setup and then restarts us
|
2017-07-04 01:16:31 +08:00
|
|
|
source test_util.fish (status -f) $argv
|
|
|
|
or exit
|
2010-10-03 11:46:26 +08:00
|
|
|
|
2014-10-03 03:31:46 +08:00
|
|
|
say -o cyan "Testing high level script functionality"
|
2010-10-03 11:46:26 +08:00
|
|
|
|
2019-06-26 02:57:37 +08:00
|
|
|
set -g python (__fish_anypython)
|
|
|
|
|
2020-03-16 09:16:14 +08:00
|
|
|
# Test littlecheck files.
|
|
|
|
set littlecheck_files (string match '*.fish' -- $files_to_test)
|
|
|
|
if set -q littlecheck_files[1]
|
2020-03-10 03:52:45 +08:00
|
|
|
$python -S ../littlecheck.py \
|
2020-03-16 09:16:14 +08:00
|
|
|
--progress \
|
2020-01-14 03:34:22 +08:00
|
|
|
-s fish=../test/root/bin/fish \
|
|
|
|
-s fish_test_helper=../test/root/bin/fish_test_helper \
|
2020-03-16 09:16:14 +08:00
|
|
|
$littlecheck_files
|
|
|
|
set -l littlecheck_failures $status
|
|
|
|
set failed (math $failed + $littlecheck_failures)
|
2014-10-03 03:31:46 +08:00
|
|
|
end
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2014-10-03 03:31:46 +08:00
|
|
|
if test $failed -eq 0
|
2020-03-29 01:41:44 +08:00
|
|
|
say green "All high level script tests completed successfully"
|
2014-10-03 03:31:46 +08:00
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
set plural (test $failed -eq 1; or echo s)
|
|
|
|
say red "$failed test$plural failed"
|
|
|
|
exit 1
|
2005-09-20 21:31:55 +08:00
|
|
|
end
|