Compile fish_test_helper in the test driver

This commit is contained in:
Fabian Boehm 2024-12-27 19:35:21 +01:00
parent b531cc8b43
commit 050fe09af1
5 changed files with 14 additions and 9 deletions

View file

@ -81,8 +81,6 @@ create_target(fish_key_reader)
# Set up the docs.
include(cmake/Docs.cmake)
# A helper for running tests.
add_executable(fish_test_helper src/fish_test_helper.c)
# Set up tests.
include(cmake/Tests.cmake)

View file

@ -89,14 +89,11 @@ add_custom_target(tests_buildroot_target
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
COMMAND env DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
# Put fish_test_helper there too:
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/fish_test_helper
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}/bin
# Also symlink fish to where the tests expect it to be:
COMMAND ${CMAKE_COMMAND} -E create_symlink
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}
${TEST_ROOT_DIR}
DEPENDS fish fish_test_helper)
DEPENDS fish)
FILE(GLOB FISH_CHECKS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/checks/*.fish)
foreach(CHECK ${FISH_CHECKS})

View file

@ -44,7 +44,7 @@ if set -q files_to_test[1]
$python -S littlecheck.py \
--progress $force_color \
-s fish=$FISHDIR/fish \
-s fish_test_helper=$FISHDIR/fish_test_helper \
-s fish_test_helper=$fish_test_helper \
-s filter-control-sequences="$FISHDIR/fish ../tests/filter-control-sequences.fish" \
$files_to_test

View file

@ -48,6 +48,16 @@ fi
# Set up the test environment. Does not change the current working directory.
. ${TESTS_ROOT}/test_env.sh
test -n "$homedir" || die "Failed to set up home"
# Compile our fish_test_helper program now.
# This takes about 50ms.
if command -v cc >/dev/null ; then
cc "$TESTS_ROOT/fish_test_helper.c" -o "$homedir/fish_test_helper"
else
echo "Cannot find a c compiler. Skipping tests that require fish_test_helper" >&2
fi
# These are used read-only so it's OK to symlink instead of copy
rm -f "$XDG_CONFIG_HOME/fish/functions"
ln -s "${TESTS_ROOT}/test_functions" "$XDG_CONFIG_HOME/fish/functions" || die "Failed to symlink"
@ -77,10 +87,10 @@ export FISH_FAST_FAIL
# 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).
if test -n "$script_args"; then
(cd $TMPDIR && env HOME="$homedir" "$fish" \
(cd $TMPDIR && env HOME="$homedir" fish_test_helper="$homedir/fish_test_helper" "$fish" \
--init-command "${fish_init_cmd}" "$fish_script" "$script_args")
else
(cd $TMPDIR && env HOME="$homedir" "$fish" \
(cd $TMPDIR && env HOME="$homedir" fish_test_helper="$homedir/fish_test_helper" "$fish" \
--init-command "${fish_init_cmd}" "$fish_script")
fi
test_status="$?"