2014-10-02 19:31:46 +00:00
|
|
|
# Fishscript tests
|
2016-02-07 02:08:22 +00: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 13:31:55 +00:00
|
|
|
|
2017-01-29 04:37:32 +00: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-23 20:20:44 +00:00
|
|
|
# Change to directory containing this script
|
2020-06-14 17:11:57 +00:00
|
|
|
cd (status dirname)
|
2014-12-23 20:20:44 +00:00
|
|
|
|
2020-03-28 17:29:21 +00:00
|
|
|
# Test files specified on commandline, or all checks.
|
2020-05-15 05:56:06 +00:00
|
|
|
set -l files_to_test
|
2014-12-23 20:20:44 +00:00
|
|
|
if set -q argv[1]
|
2020-03-28 17:29:21 +00:00
|
|
|
set files_to_test checks/$argv.fish
|
2014-12-23 20:20:44 +00:00
|
|
|
else
|
2020-03-17 20:24:37 +00:00
|
|
|
set files_to_test checks/*.fish
|
2014-12-23 20:20:44 +00:00
|
|
|
end
|
|
|
|
|
2021-03-28 18:59:14 +00: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 03:46:26 +00:00
|
|
|
|
2019-06-25 18:57:37 +00:00
|
|
|
set -g python (__fish_anypython)
|
2024-01-27 17:34:59 +00:00
|
|
|
or begin
|
|
|
|
say red "Python is not installed. These tests require python."
|
|
|
|
exit 125
|
|
|
|
end
|
2019-06-25 18:57:37 +00:00
|
|
|
|
2020-03-16 01:16:14 +00:00
|
|
|
# Test littlecheck files.
|
2021-03-28 18:59:14 +00:00
|
|
|
set -l skipped 0
|
|
|
|
set -l failed 0
|
|
|
|
if set -q files_to_test[1]
|
2021-08-30 15:16:19 +00:00
|
|
|
set -l force_color
|
|
|
|
test "$FISH_FORCE_COLOR" = 1
|
|
|
|
and set force_color --force-color
|
|
|
|
|
2020-03-09 19:52:45 +00:00
|
|
|
$python -S ../littlecheck.py \
|
2021-08-30 15:16:19 +00:00
|
|
|
--progress $force_color \
|
2020-01-13 19:34:22 +00:00
|
|
|
-s fish=../test/root/bin/fish \
|
|
|
|
-s fish_test_helper=../test/root/bin/fish_test_helper \
|
2024-04-12 10:19:32 +00:00
|
|
|
-s filter-control-sequences='../tests/filter-control-sequences.sh ../test/root/bin/fish' \
|
2021-03-28 18:59:14 +00: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-02 19:31:46 +00:00
|
|
|
end
|
2005-09-20 13:31:55 +00:00
|
|
|
|
2021-03-28 18:59:14 +00: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-02 19:31:46 +00:00
|
|
|
exit 0
|
|
|
|
else
|
2021-03-28 18:59:14 +00:00
|
|
|
test (count $files_to_test) -gt 1 && say red "$failed tests failed"
|
2014-10-02 19:31:46 +00:00
|
|
|
exit 1
|
2005-09-20 13:31:55 +00:00
|
|
|
end
|