2017-09-01 07:31:51 +00:00
|
|
|
# Define fish_tests.
|
2017-10-05 04:34:48 +00:00
|
|
|
ADD_EXECUTABLE(fish_tests EXCLUDE_FROM_ALL
|
|
|
|
src/fish_tests.cpp)
|
2020-02-12 23:02:19 +00:00
|
|
|
FISH_LINK_DEPS_AND_SIGN(fish_tests)
|
2017-09-01 07:31:51 +00:00
|
|
|
|
2017-10-05 04:34:48 +00:00
|
|
|
# The "test" directory.
|
|
|
|
SET(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
|
|
|
|
|
|
|
|
# The directory into which fish is installed.
|
|
|
|
SET(TEST_INSTALL_DIR ${TEST_DIR}/buildroot)
|
|
|
|
|
|
|
|
# The directory where the tests expect to find the fish root (./bin, etc)
|
|
|
|
SET(TEST_ROOT_DIR ${TEST_DIR}/root)
|
|
|
|
|
|
|
|
# Copy tests files.
|
|
|
|
FILE(GLOB TESTS_FILES tests/*)
|
2017-09-01 07:31:51 +00:00
|
|
|
ADD_CUSTOM_TARGET(tests_dir DEPENDS tests)
|
2018-01-06 12:07:12 +00:00
|
|
|
|
2018-01-23 09:35:43 +00:00
|
|
|
IF(NOT FISH_IN_TREE_BUILD)
|
|
|
|
ADD_CUSTOM_COMMAND(TARGET tests_dir
|
|
|
|
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 12:07:12 +00:00
|
|
|
|
2018-01-23 09:35:43 +00:00
|
|
|
ADD_DEPENDENCIES(fish_tests tests_dir)
|
|
|
|
ENDIF()
|
2017-09-01 07:31:51 +00:00
|
|
|
|
2019-06-09 18:13:31 +00:00
|
|
|
# Copy littlecheck.py
|
|
|
|
CONFIGURE_FILE(build_tools/littlecheck.py littlecheck.py COPYONLY)
|
|
|
|
|
2017-09-01 07:31:51 +00:00
|
|
|
# Make the directory in which to run tests.
|
2017-10-05 04:34:48 +00:00
|
|
|
# Also symlink fish to where the tests expect it to be.
|
2019-04-07 05:22:11 +00:00
|
|
|
# Lastly put fish_test_helper there too.
|
2017-10-05 04:34:48 +00:00
|
|
|
ADD_CUSTOM_TARGET(tests_buildroot_target
|
|
|
|
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 05:22:11 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/fish_test_helper
|
|
|
|
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}/bin
|
2017-10-05 04:34:48 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
|
|
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}
|
|
|
|
${TEST_ROOT_DIR}
|
2019-04-07 05:22:11 +00:00
|
|
|
DEPENDS fish fish_test_helper)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
2018-01-23 09:35:43 +00:00
|
|
|
IF(NOT FISH_IN_TREE_BUILD)
|
|
|
|
# We need to symlink share/functions for the tests.
|
|
|
|
# This should be simplified.
|
|
|
|
ADD_CUSTOM_TARGET(symlink_functions
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/share/functions
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/share/functions)
|
|
|
|
ADD_DEPENDENCIES(tests_buildroot_target symlink_functions)
|
|
|
|
ELSE()
|
|
|
|
ADD_CUSTOM_TARGET(symlink_functions)
|
|
|
|
ENDIF()
|
2017-10-05 04:34:48 +00:00
|
|
|
|
|
|
|
# Prep the environment for running the unit tests.
|
|
|
|
ADD_CUSTOM_TARGET(test_prep
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/data
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/home
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/temp
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory
|
|
|
|
${TEST_DIR}/data ${TEST_DIR}/home ${TEST_DIR}/temp
|
2019-07-21 18:21:50 +00:00
|
|
|
DEPENDS tests_buildroot_target tests_dir
|
2017-12-21 20:48:17 +00:00
|
|
|
USES_TERMINAL)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
2019-06-22 21:17:10 +00: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.
|
|
|
|
FOREACH(TESTTYPE test serial_test)
|
|
|
|
ADD_CUSTOM_TARGET(${TESTTYPE}_low_level
|
|
|
|
COMMAND env XDG_DATA_HOME=test/data XDG_CONFIG_HOME=test/home ./fish_tests
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS fish_tests
|
|
|
|
USES_TERMINAL)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
2019-06-22 21:17:10 +00:00
|
|
|
ADD_CUSTOM_TARGET(${TESTTYPE}_fishscript
|
|
|
|
COMMAND cd tests && ${TEST_ROOT_DIR}/bin/fish test.fish
|
|
|
|
DEPENDS test_prep
|
|
|
|
USES_TERMINAL)
|
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(${TESTTYPE}_interactive
|
|
|
|
COMMAND cd tests && ${TEST_ROOT_DIR}/bin/fish interactive.fish
|
|
|
|
DEPENDS test_prep
|
|
|
|
USES_TERMINAL)
|
2019-06-23 08:00:39 +00:00
|
|
|
ENDFOREACH(TESTTYPE)
|
2019-06-22 21:17:10 +00:00
|
|
|
|
|
|
|
# Now add a dependency chain between the serial versions.
|
|
|
|
# This ensures they run in order.
|
|
|
|
ADD_DEPENDENCIES(serial_test_fishscript serial_test_low_level)
|
2019-06-25 20:03:49 +00:00
|
|
|
ADD_DEPENDENCIES(serial_test_interactive serial_test_fishscript)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
2018-07-21 22:43:31 +00:00
|
|
|
|
2019-06-22 21:17:10 +00:00
|
|
|
ADD_CUSTOM_TARGET(serial_test_high_level
|
2019-06-25 20:03:49 +00:00
|
|
|
DEPENDS serial_test_interactive serial_test_fishscript)
|
2019-06-22 21:17:10 +00:00
|
|
|
|
|
|
|
# Create the 'test' target.
|
|
|
|
# Set a policy so CMake stops complaining about the name 'test'.
|
|
|
|
CMAKE_POLICY(PUSH)
|
2019-11-01 12:58:35 +00:00
|
|
|
|
|
|
|
IF(${CMAKE_VERSION} VERSION_LESS 3.11.0 AND POLICY CMP0037)
|
2019-06-22 21:17:10 +00:00
|
|
|
CMAKE_POLICY(SET CMP0037 OLD)
|
|
|
|
ENDIF()
|
|
|
|
ADD_CUSTOM_TARGET(test)
|
|
|
|
CMAKE_POLICY(POP)
|
|
|
|
ADD_DEPENDENCIES(test serial_test_high_level)
|
2017-10-05 04:40:58 +00:00
|
|
|
|
|
|
|
# Group test targets into a TestTargets folder
|
2019-06-22 21:17:10 +00:00
|
|
|
SET_PROPERTY(TARGET test tests_dir
|
|
|
|
test_low_level
|
|
|
|
test_fishscript
|
|
|
|
test_interactive
|
2019-06-25 20:03:49 +00:00
|
|
|
test_fishscript test_prep
|
2018-01-14 13:14:04 +00:00
|
|
|
tests_buildroot_target
|
2019-06-22 21:17:10 +00:00
|
|
|
serial_test_high_level
|
|
|
|
serial_test_low_level
|
|
|
|
serial_test_fishscript
|
|
|
|
serial_test_interactive
|
2017-10-05 04:40:58 +00:00
|
|
|
symlink_functions
|
|
|
|
PROPERTY FOLDER cmake/TestTargets)
|