Let tests find fish and associated binaries via $FISHDIR

The default is still "../test/root/bin/", but we now pass this
through,
so you *can* run

`FISHDIR=$PWD ../tests/test_driver.sh $PWD/../tests/test.fish`
This commit is contained in:
Fabian Boehm 2024-12-12 19:06:04 +01:00
parent 1df8de06c1
commit 63e705a778
4 changed files with 30 additions and 12 deletions

View File

@ -103,7 +103,7 @@ foreach(CHECK ${FISH_CHECKS})
get_filename_component(CHECK_NAME ${CHECK} NAME) get_filename_component(CHECK_NAME ${CHECK} NAME)
get_filename_component(CHECK ${CHECK} NAME_WE) get_filename_component(CHECK ${CHECK} NAME_WE)
add_test(NAME ${CHECK_NAME} add_test(NAME ${CHECK_NAME}
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh COMMAND env FISHDIR=${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
${CMAKE_CURRENT_BINARY_DIR}/tests/test.fish ${CHECK} ${CMAKE_CURRENT_BINARY_DIR}/tests/test.fish ${CHECK}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
) )
@ -116,7 +116,7 @@ FILE(GLOB PEXPECTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/pexpects/*.py)
foreach(PEXPECT ${PEXPECTS}) foreach(PEXPECT ${PEXPECTS})
get_filename_component(PEXPECT ${PEXPECT} NAME) get_filename_component(PEXPECT ${PEXPECT} NAME)
add_test(NAME ${PEXPECT} add_test(NAME ${PEXPECT}
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh COMMAND env FISHDIR=${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
${CMAKE_CURRENT_BINARY_DIR}/tests/interactive.fish ${PEXPECT} ${CMAKE_CURRENT_BINARY_DIR}/tests/interactive.fish ${PEXPECT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
) )

View File

@ -31,10 +31,12 @@ function test_pexpect_file
set -lx TERM dumb set -lx TERM dumb
# Help the script find the pexpect_helper module in our parent directory. # Help the script find the pexpect_helper module in our parent directory.
set -q FISHDIR
or set -l FISHDIR ../test/root/bin/
set -lx --prepend PYTHONPATH (realpath $PWD) set -lx --prepend PYTHONPATH (realpath $PWD)
set -lx fish ../test/root/bin/fish set -lx fish $FISHDIR/fish
set -lx fish_key_reader ../test/root/bin/fish_key_reader set -lx fish_key_reader $FISHDIR/fish_key_reader
set -lx fish_test_helper ../test/root/bin/fish_test_helper set -lx fish_test_helper $FISHDIR/fish_test_helper
# Note we require Python3. # Note we require Python3.
python3 $file python3 $file

View File

@ -30,6 +30,9 @@ or begin
exit 125 exit 125
end end
set -q FISHDIR
or set -l FISHDIR ../test/root/bin
# Test littlecheck files. # Test littlecheck files.
set -l skipped 0 set -l skipped 0
set -l failed 0 set -l failed 0
@ -40,9 +43,9 @@ if set -q files_to_test[1]
$python -S littlecheck.py \ $python -S littlecheck.py \
--progress $force_color \ --progress $force_color \
-s fish=../test/root/bin/fish \ -s fish=$FISHDIR/fish \
-s fish_test_helper=../test/root/bin/fish_test_helper \ -s fish_test_helper=$FISHDIR/fish_test_helper \
-s filter-control-sequences='../test/root/bin/fish ../tests/filter-control-sequences.fish' \ -s filter-control-sequences="$FISHDIR/fish ../tests/filter-control-sequences.fish" \
$files_to_test $files_to_test
set -l littlecheck_status $status set -l littlecheck_status $status

21
tests/test_driver.sh Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/bin/sh
# vim: set ts=4 sw=4 tw=100 et: # vim: set ts=4 sw=4 tw=100 et:
# POSIX sh test driver to reduce dependency on fish in tests. # POSIX sh test driver to reduce dependency on fish in tests.
@ -12,9 +13,13 @@
# Folks, this is why you should use fish! # Folks, this is why you should use fish!
IFS="$(printf "\n\b")" IFS="$(printf "\n\b")"
# If CDPATH is set, `cd foo` will print the directory.
unset CDPATH
# The first argument is the path to the script to launch; all remaining arguments are forwarded to # The first argument is the path to the script to launch; all remaining arguments are forwarded to
# the script. # the script.
fish_script="$1" # Resolve the script now because we are going to `cd` later.
fish_script="$(realpath $1)"
shift 1 shift 1
script_args="${@}" script_args="${@}"
# Prevent $@ from persisting to sourced commands # Prevent $@ from persisting to sourced commands
@ -32,6 +37,9 @@ die() {
TESTS_ROOT="$(cd $(dirname "$0") && pwd -P)" TESTS_ROOT="$(cd $(dirname "$0") && pwd -P)"
BUILD_ROOT="$(cd $(dirname "$TESTS_ROOT") && pwd -P)" BUILD_ROOT="$(cd $(dirname "$TESTS_ROOT") && pwd -P)"
test -n "$FISHDIR" && FISHDIR=$(realpath -- "$FISHDIR")
fish="${FISHDIR:-${BUILD_ROOT}/test/root/bin}/fish"
if ! test -z "$__fish_is_running_tests"; then if ! test -z "$__fish_is_running_tests"; then
echo "Recursive test invocation detected!" 1>&2 echo "Recursive test invocation detected!" 1>&2
exit 10 exit 10
@ -42,7 +50,7 @@ fi
# These are used read-only so it's OK to symlink instead of copy # These are used read-only so it's OK to symlink instead of copy
rm -f "$XDG_CONFIG_HOME/fish/functions" rm -f "$XDG_CONFIG_HOME/fish/functions"
ln -s "$PWD/test_functions" "$XDG_CONFIG_HOME/fish/functions" || die "Failed to symlink" ln -s "${TESTS_ROOT}/test_functions" "$XDG_CONFIG_HOME/fish/functions" || die "Failed to symlink"
# Set the function path at startup, referencing the default fish functions and the test-specific # Set the function path at startup, referencing the default fish functions and the test-specific
# functions. # functions.
@ -68,8 +76,13 @@ export FISH_FAST_FAIL
# Run the test script, but don't exec so we can clean up after it succeeds/fails. Each test is # Run the test script, but don't exec so we can clean up after it succeeds/fails. Each test is
# launched directly within its TMPDIR, so that the fish tests themselves do not need to refer to # launched directly within its TMPDIR, so that the fish tests themselves do not need to refer to
# TMPDIR (to ensure their output as displayed in case of failure by littlecheck is reproducible). # TMPDIR (to ensure their output as displayed in case of failure by littlecheck is reproducible).
(cd $TMPDIR && env HOME="$homedir" "${BUILD_ROOT}/test/root/bin/fish" \ if test -n "$script_args"; then
--init-command "${fish_init_cmd}" "$fish_script" "$script_args") (cd $TMPDIR && env HOME="$homedir" "$fish" \
--init-command "${fish_init_cmd}" "$fish_script" "$script_args")
else
(cd $TMPDIR && env HOME="$homedir" "$fish" \
--init-command "${fish_init_cmd}" "$fish_script")
fi
test_status="$?" test_status="$?"
rm -rf "$homedir" rm -rf "$homedir"