2017-09-01 15:31:51 +08:00
|
|
|
# Define fish_tests.
|
2020-03-15 07:11:35 +08:00
|
|
|
add_executable(fish_tests EXCLUDE_FROM_ALL
|
2017-10-05 12:34:48 +08:00
|
|
|
src/fish_tests.cpp)
|
2020-03-15 07:11:35 +08:00
|
|
|
fish_link_deps_and_sign(fish_tests)
|
2017-09-01 15:31:51 +08:00
|
|
|
|
2017-10-05 12:34:48 +08:00
|
|
|
# The "test" directory.
|
2020-03-15 07:11:35 +08:00
|
|
|
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
|
|
|
# The directory into which fish is installed.
|
2020-03-15 07:11:35 +08:00
|
|
|
set(TEST_INSTALL_DIR ${TEST_DIR}/buildroot)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
|
|
|
# The directory where the tests expect to find the fish root (./bin, etc)
|
2020-03-15 07:11:35 +08:00
|
|
|
set(TEST_ROOT_DIR ${TEST_DIR}/root)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
|
|
|
# Copy tests files.
|
2020-03-15 07:11:35 +08:00
|
|
|
file(GLOB TESTS_FILES tests/*)
|
|
|
|
add_custom_target(tests_dir DEPENDS tests)
|
2018-01-06 20:07:12 +08:00
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
if(NOT FISH_IN_TREE_BUILD)
|
|
|
|
add_custom_command(TARGET tests_dir
|
2018-01-23 17:35:43 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
${CMAKE_SOURCE_DIR}/tests/ ${CMAKE_BINARY_DIR}/tests/
|
|
|
|
COMMENT "Copying test files to binary dir"
|
|
|
|
VERBATIM)
|
2018-01-06 20:07:12 +08:00
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
add_dependencies(fish_tests tests_dir)
|
|
|
|
endif()
|
2017-09-01 15:31:51 +08:00
|
|
|
|
2019-06-10 02:13:31 +08:00
|
|
|
# Copy littlecheck.py
|
2020-03-15 07:11:35 +08:00
|
|
|
configure_file(build_tools/littlecheck.py littlecheck.py COPYONLY)
|
2019-06-10 02:13:31 +08:00
|
|
|
|
2020-03-03 07:20:29 +08:00
|
|
|
# Copy pexpect_helper.py
|
|
|
|
configure_file(build_tools/pexpect_helper.py pexpect_helper.py COPYONLY)
|
|
|
|
|
2017-09-01 15:31:51 +08:00
|
|
|
# Make the directory in which to run tests.
|
2017-10-05 12:34:48 +08:00
|
|
|
# Also symlink fish to where the tests expect it to be.
|
2019-04-07 13:22:11 +08:00
|
|
|
# Lastly put fish_test_helper there too.
|
2020-03-15 07:11:35 +08:00
|
|
|
add_custom_target(tests_buildroot_target
|
2017-10-05 12:34:48 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
|
|
|
|
COMMAND DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
|
|
|
|
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
|
2019-04-07 13:22:11 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/fish_test_helper
|
|
|
|
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}/bin
|
2017-10-05 12:34:48 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
|
|
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}
|
|
|
|
${TEST_ROOT_DIR}
|
2019-04-07 13:22:11 +08:00
|
|
|
DEPENDS fish fish_test_helper)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
if(NOT FISH_IN_TREE_BUILD)
|
2018-01-23 17:35:43 +08:00
|
|
|
# We need to symlink share/functions for the tests.
|
|
|
|
# This should be simplified.
|
2020-03-15 07:11:35 +08:00
|
|
|
add_custom_target(symlink_functions
|
2018-01-23 17:35:43 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/share/functions
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/share/functions)
|
2020-03-15 07:11:35 +08:00
|
|
|
add_dependencies(tests_buildroot_target symlink_functions)
|
|
|
|
else()
|
|
|
|
add_custom_target(symlink_functions)
|
|
|
|
endif()
|
2017-10-05 12:34:48 +08:00
|
|
|
|
|
|
|
# Prep the environment for running the unit tests.
|
2020-03-15 07:11:35 +08:00
|
|
|
add_custom_target(test_prep
|
2020-10-26 10:57:45 +08:00
|
|
|
# Add directories hard-coded into the tests
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/data
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/data
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/temp
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/temp
|
|
|
|
|
|
|
|
# Add the XDG_* directories
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_data
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_data
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_config
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_config
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_runtime
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_runtime
|
|
|
|
|
|
|
|
DEPENDS tests_buildroot_target tests_dir
|
|
|
|
USES_TERMINAL)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
2019-06-23 05:17:10 +08:00
|
|
|
# Define our individual tests.
|
|
|
|
# Each test is conceptually independent.
|
|
|
|
# However when running all tests, we want to run them serially for sanity's sake.
|
|
|
|
# So define both a normal target, and a serial variant which enforces ordering.
|
2020-03-15 07:11:35 +08:00
|
|
|
foreach(TESTTYPE test serial_test)
|
|
|
|
add_custom_target(${TESTTYPE}_low_level
|
2021-04-21 06:43:28 +08:00
|
|
|
COMMAND env -u XDG_DATA_DIRS
|
|
|
|
XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
2020-10-26 10:57:45 +08:00
|
|
|
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
2021-04-21 06:43:28 +08:00
|
|
|
XDG_RUNTIME_DIR=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
2020-10-26 10:57:45 +08:00
|
|
|
./fish_tests
|
2019-06-23 05:17:10 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS fish_tests
|
|
|
|
USES_TERMINAL)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
add_custom_target(${TESTTYPE}_fishscript
|
2020-10-26 10:57:45 +08:00
|
|
|
COMMAND
|
|
|
|
cd tests &&
|
2021-04-21 06:43:28 +08:00
|
|
|
env -u XDG_DATA_DIRS
|
|
|
|
XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
2020-10-26 10:57:45 +08:00
|
|
|
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
2021-04-21 06:43:28 +08:00
|
|
|
XDG_RUNTIME_DIR=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
2020-10-26 10:57:45 +08:00
|
|
|
${TEST_ROOT_DIR}/bin/fish test.fish
|
2019-06-23 05:17:10 +08:00
|
|
|
DEPENDS test_prep
|
|
|
|
USES_TERMINAL)
|
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
add_custom_target(${TESTTYPE}_interactive
|
2020-10-26 10:57:45 +08:00
|
|
|
COMMAND cd tests &&
|
2021-04-21 06:43:28 +08:00
|
|
|
env -u XDG_DATA_DIRS
|
|
|
|
XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
2020-10-26 10:57:45 +08:00
|
|
|
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
2021-04-21 06:43:28 +08:00
|
|
|
XDG_RUNTIME_DIR=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
2020-10-26 10:57:45 +08:00
|
|
|
${TEST_ROOT_DIR}/bin/fish interactive.fish
|
2019-06-23 05:17:10 +08:00
|
|
|
DEPENDS test_prep
|
|
|
|
USES_TERMINAL)
|
2020-03-15 07:11:35 +08:00
|
|
|
endforeach(TESTTYPE)
|
2019-06-23 05:17:10 +08:00
|
|
|
|
|
|
|
# Now add a dependency chain between the serial versions.
|
|
|
|
# This ensures they run in order.
|
2021-03-09 05:11:47 +08:00
|
|
|
add_dependencies(serial_test_low_level test_prep)
|
2020-03-15 07:11:35 +08:00
|
|
|
add_dependencies(serial_test_fishscript serial_test_low_level)
|
|
|
|
add_dependencies(serial_test_interactive serial_test_fishscript)
|
2017-10-05 12:34:48 +08:00
|
|
|
|
2018-07-22 06:43:31 +08:00
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
add_custom_target(serial_test_high_level
|
2019-06-26 04:03:49 +08:00
|
|
|
DEPENDS serial_test_interactive serial_test_fishscript)
|
2019-06-23 05:17:10 +08:00
|
|
|
|
|
|
|
# Create the 'test' target.
|
|
|
|
# Set a policy so CMake stops complaining about the name 'test'.
|
2020-03-15 07:11:35 +08:00
|
|
|
cmake_policy(PUSH)
|
2019-11-01 20:58:35 +08:00
|
|
|
|
2020-03-15 07:11:35 +08:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.11.0 AND POLICY CMP0037)
|
|
|
|
cmake_policy(SET CMP0037 OLD)
|
|
|
|
endif()
|
|
|
|
add_custom_target(test)
|
|
|
|
cmake_policy(POP)
|
|
|
|
add_dependencies(test serial_test_high_level)
|
2017-10-05 12:40:58 +08:00
|
|
|
|
|
|
|
# Group test targets into a TestTargets folder
|
2020-03-15 07:11:35 +08:00
|
|
|
set_property(TARGET test tests_dir
|
2019-06-23 05:17:10 +08:00
|
|
|
test_low_level
|
|
|
|
test_fishscript
|
|
|
|
test_interactive
|
2019-06-26 04:03:49 +08:00
|
|
|
test_fishscript test_prep
|
2018-01-14 21:14:04 +08:00
|
|
|
tests_buildroot_target
|
2019-06-23 05:17:10 +08:00
|
|
|
serial_test_high_level
|
|
|
|
serial_test_low_level
|
|
|
|
serial_test_fishscript
|
|
|
|
serial_test_interactive
|
2017-10-05 12:40:58 +08:00
|
|
|
symlink_functions
|
|
|
|
PROPERTY FOLDER cmake/TestTargets)
|