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
|
|
|
|
|
2021-03-29 02:59:14 +08:00
|
|
|
# Be less verbose when running tests one-by-one
|
|
|
|
if test (count $files_to_test) -gt 1
|
|
|
|
say -o cyan "Testing high level script functionality"
|
|
|
|
end
|
2010-10-03 11:46:26 +08:00
|
|
|
|
2019-06-26 02:57:37 +08:00
|
|
|
set -g python (__fish_anypython)
|
2024-01-28 01:34:59 +08:00
|
|
|
or begin
|
|
|
|
say red "Python is not installed. These tests require python."
|
|
|
|
exit 125
|
|
|
|
end
|
2019-06-26 02:57:37 +08:00
|
|
|
|
2020-03-16 09:16:14 +08:00
|
|
|
# Test littlecheck files.
|
2021-03-29 02:59:14 +08:00
|
|
|
set -l skipped 0
|
|
|
|
set -l failed 0
|
|
|
|
if set -q files_to_test[1]
|
2021-08-30 23:16:19 +08:00
|
|
|
set -l force_color
|
|
|
|
test "$FISH_FORCE_COLOR" = 1
|
|
|
|
and set force_color --force-color
|
|
|
|
|
2020-03-10 03:52:45 +08:00
|
|
|
$python -S ../littlecheck.py \
|
2021-08-30 23:16:19 +08:00
|
|
|
--progress $force_color \
|
2020-01-14 03:34:22 +08:00
|
|
|
-s fish=../test/root/bin/fish \
|
|
|
|
-s fish_test_helper=../test/root/bin/fish_test_helper \
|
2024-11-22 04:07:40 +08:00
|
|
|
-s filter-control-sequences='../test/root/bin/fish ../tests/filter-control-sequences.fish' \
|
2021-03-29 02:59:14 +08:00
|
|
|
$files_to_test
|
|
|
|
|
|
|
|
set -l littlecheck_status $status
|
|
|
|
if test "$littlecheck_status" -eq 125
|
|
|
|
# 125 indicates that all tests executed were skipped.
|
|
|
|
set skipped (count $files_to_test)
|
|
|
|
else
|
|
|
|
# The return code indicates the number of tests that failed
|
|
|
|
set failed $littlecheck_status
|
|
|
|
end
|
2014-10-03 03:31:46 +08:00
|
|
|
end
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2021-03-29 02:59:14 +08:00
|
|
|
if test $failed -eq 0 && test $skipped -gt 0
|
|
|
|
test (count $files_to_test) -gt 1 && say blue (count $files_to_test)" tests skipped"
|
|
|
|
exit 125
|
|
|
|
else if test $failed -eq 0
|
|
|
|
test (count $files_to_test) -gt 1 && say green "All high level script tests completed successfully"
|
2014-10-03 03:31:46 +08:00
|
|
|
exit 0
|
|
|
|
else
|
2021-03-29 02:59:14 +08:00
|
|
|
test (count $files_to_test) -gt 1 && say red "$failed tests failed"
|
2014-10-03 03:31:46 +08:00
|
|
|
exit 1
|
2005-09-20 21:31:55 +08:00
|
|
|
end
|