2021-03-15 17:42:53 +00:00
|
|
|
# This adds ctest support to the project
|
|
|
|
enable_testing()
|
|
|
|
|
2021-09-20 19:51:24 +00:00
|
|
|
# Put in a tests folder to reduce the top level targets in IDEs.
|
|
|
|
set(CMAKE_FOLDER tests)
|
|
|
|
|
2021-03-28 18:59:14 +00:00
|
|
|
# We will use 125 as a reserved exit code to indicate that a test has been skipped, i.e. it did not
|
|
|
|
# pass but it should not be considered a failed test run, either.
|
|
|
|
set(SKIP_RETURN_CODE 125)
|
|
|
|
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
# Even though we are using CMake's ctest for testing, we still define our own `make test` target
|
|
|
|
# rather than use its default for many reasons:
|
|
|
|
# * CMake doesn't run tests in-proc or even add each tests as an individual node in the ninja
|
|
|
|
# dependency tree, instead it just bundles all tests into a target called `test` that always just
|
|
|
|
# shells out to `ctest`, so there are no build-related benefits to not doing that ourselves.
|
|
|
|
# * CMake devs insist that it is appropriate for `make test` to never depend on `make all`, i.e.
|
|
|
|
# running `make test` does not require any of the binaries to be built before testing.
|
|
|
|
# * The only way to have a test depend on a binary is to add a fake test with a name like
|
|
|
|
# "build_fish" that executes CMake recursively to build the `fish` target.
|
|
|
|
# * Circling back to the point about individual tests not being actual Makefile targets, CMake does
|
|
|
|
# not offer any way to execute a named test via the `make`/`ninja`/whatever interface; the only
|
|
|
|
# way to manually invoke test `foo` is to to manually run `ctest` and specify a regex matching
|
|
|
|
# `foo` as an argument, e.g. `ctest -R ^foo$`... which is really crazy.
|
|
|
|
|
2021-11-26 21:07:40 +00:00
|
|
|
# The top-level test target is "fish_run_tests".
|
|
|
|
add_custom_target(fish_run_tests
|
2024-03-30 15:10:12 +00:00
|
|
|
COMMAND env FISH_FORCE_COLOR=1
|
2021-10-18 15:00:19 +00:00
|
|
|
FISH_SOURCE_DIR=${CMAKE_SOURCE_DIR}
|
2021-09-07 16:33:56 +00:00
|
|
|
${CMAKE_CTEST_COMMAND} --force-new-ctest-process # --verbose
|
2021-08-29 21:03:23 +00:00
|
|
|
--output-on-failure --progress
|
2024-01-07 11:00:19 +00:00
|
|
|
DEPENDS tests_dir funcs_dir tests_buildroot_target
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2021-11-26 21:07:40 +00:00
|
|
|
|
|
|
|
# If CMP0037 is available, also make an alias "test" target.
|
|
|
|
# Note that this policy may not be available, in which case definining such a target silently fails.
|
|
|
|
cmake_policy(PUSH)
|
|
|
|
if(POLICY CMP0037)
|
|
|
|
cmake_policy(SET CMP0037 OLD)
|
|
|
|
add_custom_target(test DEPENDS fish_run_tests)
|
|
|
|
endif()
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
cmake_policy(POP)
|
|
|
|
|
2017-10-05 04:34:48 +00:00
|
|
|
# The "test" directory.
|
2020-03-14 23:11:35 +00:00
|
|
|
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
|
|
|
# The directory into which fish is installed.
|
2020-03-14 23:11:35 +00:00
|
|
|
set(TEST_INSTALL_DIR ${TEST_DIR}/buildroot)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
|
|
|
# The directory where the tests expect to find the fish root (./bin, etc)
|
2020-03-14 23:11:35 +00:00
|
|
|
set(TEST_ROOT_DIR ${TEST_DIR}/root)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
# Copy needed directories for out-of-tree builds
|
2020-03-14 23:11:35 +00:00
|
|
|
if(NOT FISH_IN_TREE_BUILD)
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
add_custom_target(funcs_dir)
|
|
|
|
add_custom_command(TARGET funcs_dir
|
2021-09-02 15:27:10 +00:00
|
|
|
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/share
|
|
|
|
# Don't run ln twice or it will create a new link in the link.
|
|
|
|
COMMAND test -e ${CMAKE_BINARY_DIR}/share/functions || ln -sf
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
${CMAKE_SOURCE_DIR}/share/functions/ ${CMAKE_BINARY_DIR}/share/functions
|
|
|
|
COMMENT "Symlinking fish functions to binary dir"
|
|
|
|
VERBATIM)
|
|
|
|
|
|
|
|
add_custom_target(tests_dir DEPENDS tests)
|
|
|
|
add_custom_command(TARGET tests_dir
|
2018-01-23 09:35:43 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
${CMAKE_SOURCE_DIR}/tests/ ${CMAKE_BINARY_DIR}/tests/
|
|
|
|
COMMENT "Copying test files to binary dir"
|
|
|
|
VERBATIM)
|
2020-03-14 23:11:35 +00:00
|
|
|
endif()
|
2017-09-01 07:31:51 +00:00
|
|
|
|
2019-06-09 18:13:31 +00:00
|
|
|
# Copy littlecheck.py
|
2020-03-14 23:11:35 +00:00
|
|
|
configure_file(build_tools/littlecheck.py littlecheck.py COPYONLY)
|
2019-06-09 18:13:31 +00:00
|
|
|
|
2020-03-02 23:20:29 +00:00
|
|
|
# Copy pexpect_helper.py
|
|
|
|
configure_file(build_tools/pexpect_helper.py pexpect_helper.py COPYONLY)
|
|
|
|
|
2021-09-19 05:09:31 +00:00
|
|
|
# Suppress generating Xcode schemes for all tests, there's too many.
|
|
|
|
set(CMAKE_XCODE_GENERATE_SCHEME 0)
|
|
|
|
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
# CMake being CMake, you can't just add a DEPENDS argument to add_test to make it depend on any of
|
|
|
|
# your binaries actually being built before `make test` is executed (requiring `make all` first),
|
2024-01-07 11:00:19 +00:00
|
|
|
# and the only dependency a test can have is on another test. So we make building fish
|
|
|
|
# prerequisites to our entire top-level `test` target.
|
2021-07-31 00:07:17 +00:00
|
|
|
function(add_test_target NAME)
|
2021-11-10 01:07:15 +00:00
|
|
|
string(REPLACE "/" "-" NAME ${NAME})
|
|
|
|
add_custom_target("test_${NAME}" COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R "^${NAME}$$"
|
2024-01-07 11:00:19 +00:00
|
|
|
DEPENDS tests_dir funcs_dir tests_buildroot_target USES_TERMINAL )
|
2021-07-31 00:07:17 +00:00
|
|
|
endfunction()
|
|
|
|
|
2020-03-14 23:11:35 +00:00
|
|
|
add_custom_target(tests_buildroot_target
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
# Make the directory in which to run tests:
|
2017-10-05 04:34:48 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
|
2021-10-22 09:27:19 +00:00
|
|
|
COMMAND env DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
|
2017-10-05 04:34:48 +00:00
|
|
|
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
# Put fish_test_helper there too:
|
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
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
# Also symlink fish to where the tests expect it to be:
|
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
|
|
|
|
2021-03-15 17:42:53 +00:00
|
|
|
FILE(GLOB FISH_CHECKS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/checks/*.fish)
|
|
|
|
foreach(CHECK ${FISH_CHECKS})
|
|
|
|
get_filename_component(CHECK_NAME ${CHECK} NAME)
|
|
|
|
get_filename_component(CHECK ${CHECK} NAME_WE)
|
|
|
|
add_test(NAME ${CHECK_NAME}
|
2024-01-20 08:10:46 +00:00
|
|
|
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
|
2021-03-15 17:42:53 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/tests/test.fish ${CHECK}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
|
|
|
)
|
2021-03-28 18:59:14 +00:00
|
|
|
set_tests_properties(${CHECK_NAME} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
2022-04-10 20:40:51 +00:00
|
|
|
set_tests_properties(${CHECK_NAME} PROPERTIES ENVIRONMENT FISH_FORCE_COLOR=1)
|
Make `test` a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:
* CMake doesn't run tests in-proc or even add each tests as an
individual node in the ninja dependency tree, instead it just bundles
all tests into a target called `test` that always just shells out to
`ctest`, so there are no build-related benefits to not doing that
ourselves.
* CMake devs insist that it is appropriate for `make test` to never
depend on `make all`, i.e. running `make test` does not require any
of the binaries to be built before testing.
* The only way to have a test depend on a binary is to add a fake test
with a name like "build_fish" that executes CMake recursively to
build the `fish` target.
* It is not possible to set top-level CTest options/settings such as
CTEST_PARALLEL_LEVEL from within the CMake configuration file.
* Circling back to the point about individual tests not being actual
Makefile targets, CMake does not offer any way to execute a named
test via the `make`/`ninja`/whatever interface; the only way to
manually invoke test `foo` is to to manually run `ctest` and specify
a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
is really crazy.
With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-08 23:31:50 +00:00
|
|
|
add_test_target("${CHECK_NAME}")
|
2021-03-15 17:42:53 +00:00
|
|
|
endforeach(CHECK)
|
2021-03-18 18:23:31 +00:00
|
|
|
|
|
|
|
FILE(GLOB PEXPECTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/pexpects/*.py)
|
|
|
|
foreach(PEXPECT ${PEXPECTS})
|
|
|
|
get_filename_component(PEXPECT ${PEXPECT} NAME)
|
|
|
|
add_test(NAME ${PEXPECT}
|
2024-01-20 08:10:46 +00:00
|
|
|
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
|
2021-03-18 18:23:31 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/tests/interactive.fish ${PEXPECT}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
|
|
|
)
|
2021-03-28 18:59:14 +00:00
|
|
|
set_tests_properties(${PEXPECT} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
2022-04-10 20:40:51 +00:00
|
|
|
set_tests_properties(${PEXPECT} PROPERTIES ENVIRONMENT FISH_FORCE_COLOR=1)
|
2021-03-18 18:23:31 +00:00
|
|
|
add_test_target("${PEXPECT}")
|
|
|
|
endforeach(PEXPECT)
|
2023-01-14 22:56:24 +00:00
|
|
|
|
2024-01-13 00:26:28 +00:00
|
|
|
set(cargo_test_flags)
|
2023-01-14 22:56:24 +00:00
|
|
|
# Rust stuff.
|
2023-03-07 00:15:36 +00:00
|
|
|
if(DEFINED ASAN)
|
|
|
|
# Rust w/ -Zsanitizer=address requires explicitly specifying the --target triple or else linker
|
|
|
|
# errors pertaining to asan symbols will ensue.
|
|
|
|
if(NOT DEFINED Rust_CARGO_TARGET)
|
|
|
|
message(FATAL_ERROR "ASAN requires defining the CMake variable Rust_CARGO_TARGET to the
|
|
|
|
intended target triple")
|
|
|
|
endif()
|
2024-06-21 16:56:50 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED Rust_CARGO_TARGET)
|
2024-01-13 00:26:28 +00:00
|
|
|
list(APPEND cargo_test_flags "--target" ${Rust_CARGO_TARGET})
|
|
|
|
list(APPEND cargo_test_flags "--lib")
|
2023-03-07 00:15:36 +00:00
|
|
|
endif()
|
|
|
|
|
2024-01-07 20:38:49 +00:00
|
|
|
add_test(
|
|
|
|
NAME "cargo-test"
|
2024-05-12 22:36:48 +00:00
|
|
|
COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --workspace --target-dir ${rust_target_dir} ${cargo_test_flags}
|
2024-01-07 20:38:49 +00:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
)
|
|
|
|
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
|
|
|
add_test_target("cargo-test")
|