mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-12 16:56:32 +08:00
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:
parent
1df8de06c1
commit
63e705a778
|
@ -103,7 +103,7 @@ foreach(CHECK ${FISH_CHECKS})
|
|||
get_filename_component(CHECK_NAME ${CHECK} NAME)
|
||||
get_filename_component(CHECK ${CHECK} NAME_WE)
|
||||
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}
|
||||
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})
|
||||
get_filename_component(PEXPECT ${PEXPECT} NAME)
|
||||
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}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
|
|
|
@ -31,10 +31,12 @@ function test_pexpect_file
|
|||
set -lx TERM dumb
|
||||
|
||||
# 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 fish ../test/root/bin/fish
|
||||
set -lx fish_key_reader ../test/root/bin/fish_key_reader
|
||||
set -lx fish_test_helper ../test/root/bin/fish_test_helper
|
||||
set -lx fish $FISHDIR/fish
|
||||
set -lx fish_key_reader $FISHDIR/fish_key_reader
|
||||
set -lx fish_test_helper $FISHDIR/fish_test_helper
|
||||
|
||||
# Note we require Python3.
|
||||
python3 $file
|
||||
|
|
|
@ -30,6 +30,9 @@ or begin
|
|||
exit 125
|
||||
end
|
||||
|
||||
set -q FISHDIR
|
||||
or set -l FISHDIR ../test/root/bin
|
||||
|
||||
# Test littlecheck files.
|
||||
set -l skipped 0
|
||||
set -l failed 0
|
||||
|
@ -40,9 +43,9 @@ if set -q files_to_test[1]
|
|||
|
||||
$python -S littlecheck.py \
|
||||
--progress $force_color \
|
||||
-s fish=../test/root/bin/fish \
|
||||
-s fish_test_helper=../test/root/bin/fish_test_helper \
|
||||
-s filter-control-sequences='../test/root/bin/fish ../tests/filter-control-sequences.fish' \
|
||||
-s fish=$FISHDIR/fish \
|
||||
-s fish_test_helper=$FISHDIR/fish_test_helper \
|
||||
-s filter-control-sequences="$FISHDIR/fish ../tests/filter-control-sequences.fish" \
|
||||
$files_to_test
|
||||
|
||||
set -l littlecheck_status $status
|
||||
|
|
21
tests/test_driver.sh
Normal file → Executable file
21
tests/test_driver.sh
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
|||
#!/bin/sh
|
||||
# vim: set ts=4 sw=4 tw=100 et:
|
||||
|
||||
# POSIX sh test driver to reduce dependency on fish in tests.
|
||||
|
@ -12,9 +13,13 @@
|
|||
# Folks, this is why you should use fish!
|
||||
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 script.
|
||||
fish_script="$1"
|
||||
# Resolve the script now because we are going to `cd` later.
|
||||
fish_script="$(realpath $1)"
|
||||
shift 1
|
||||
script_args="${@}"
|
||||
# Prevent $@ from persisting to sourced commands
|
||||
|
@ -32,6 +37,9 @@ die() {
|
|||
TESTS_ROOT="$(cd $(dirname "$0") && 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
|
||||
echo "Recursive test invocation detected!" 1>&2
|
||||
exit 10
|
||||
|
@ -42,7 +50,7 @@ fi
|
|||
|
||||
# These are used read-only so it's OK to symlink instead of copy
|
||||
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
|
||||
# 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
|
||||
# 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).
|
||||
(cd $TMPDIR && env HOME="$homedir" "${BUILD_ROOT}/test/root/bin/fish" \
|
||||
--init-command "${fish_init_cmd}" "$fish_script" "$script_args")
|
||||
if test -n "$script_args"; then
|
||||
(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="$?"
|
||||
|
||||
rm -rf "$homedir"
|
||||
|
|
Loading…
Reference in New Issue
Block a user