From 050fe09af12929c1f79dd1796a504593400ef84a Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 27 Dec 2024 19:35:21 +0100 Subject: [PATCH] Compile fish_test_helper in the test driver --- CMakeLists.txt | 2 -- cmake/Tests.cmake | 5 +---- {src => tests}/fish_test_helper.c | 0 tests/test.fish | 2 +- tests/test_driver.sh | 14 ++++++++++++-- 5 files changed, 14 insertions(+), 9 deletions(-) rename {src => tests}/fish_test_helper.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 496226e89..dafa3e145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/Tests.cmake b/cmake/Tests.cmake index 0b0e1734f..87bec586d 100644 --- a/cmake/Tests.cmake +++ b/cmake/Tests.cmake @@ -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}) diff --git a/src/fish_test_helper.c b/tests/fish_test_helper.c similarity index 100% rename from src/fish_test_helper.c rename to tests/fish_test_helper.c diff --git a/tests/test.fish b/tests/test.fish index f68df0b7c..0f4f7f798 100644 --- a/tests/test.fish +++ b/tests/test.fish @@ -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 diff --git a/tests/test_driver.sh b/tests/test_driver.sh index 80188135b..bbdcedae6 100755 --- a/tests/test_driver.sh +++ b/tests/test_driver.sh @@ -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="$?"