2021-03-15 17:42:53 +00:00
|
|
|
# This adds ctest support to the project
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
# By default, ctest runs tests serially
|
|
|
|
if(NOT CTEST_PARALLEL_LEVEL)
|
|
|
|
include(ProcessorCount)
|
|
|
|
ProcessorCount(CORES)
|
|
|
|
set(CTEST_PARALLEL_LEVEL ${CORES})
|
|
|
|
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
|
|
|
# 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.
|
|
|
|
|
|
|
|
# Set a policy so CMake stops complaining when we use the target name "test"
|
|
|
|
cmake_policy(PUSH)
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.11.0 AND POLICY CMP0037)
|
|
|
|
cmake_policy(SET CMP0037 OLD)
|
|
|
|
endif()
|
|
|
|
add_custom_target(test
|
|
|
|
COMMAND env CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL}
|
|
|
|
${CMAKE_CTEST_COMMAND} --force-new-ctest-process
|
|
|
|
--output-on-failure
|
|
|
|
DEPENDS fish_tests tests_buildroot_target
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
cmake_policy(POP)
|
|
|
|
|
|
|
|
# Build the low-level tests code
|
2020-03-14 23:11:35 +00:00
|
|
|
add_executable(fish_tests EXCLUDE_FROM_ALL
|
2017-10-05 04:34:48 +00:00
|
|
|
src/fish_tests.cpp)
|
2020-03-14 23:11:35 +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.
|
2020-03-14 23:11:35 +00:00
|
|
|
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
|
2017-10-05 04:34:48 +00:00
|
|
|
|
2021-07-31 00:51:42 +00:00
|
|
|
# CMake doesn't really support dynamic test discovery where a test harness is executed to list the
|
|
|
|
# tests it contains, making fish_tests.cpp's tests opaque to CMake (whereas littlecheck tests can be
|
|
|
|
# enumerated from the filesystem). We used to compile fish_tests.cpp without linking against
|
|
|
|
# anything (-Wl,-undefined,dynamic_lookup,--unresolved-symbols=ignore-all) to get it to print its
|
|
|
|
# tests at configuration time, but that's a little too much dark CMake magic.
|
|
|
|
#
|
|
|
|
# We now identify tests by checking against a magic regex that's #define'd as a no-op C-side.
|
|
|
|
file(READ "${CMAKE_SOURCE_DIR}/src/fish_tests.cpp" FISH_TESTS_CPP)
|
|
|
|
string(REGEX MATCHALL "TEST_GROUP\\( *\"([^\"]+)\"" "LOW_LEVEL_TESTS" "${FISH_TESTS_CPP}")
|
|
|
|
string(REGEX REPLACE "TEST_GROUP\\( *\"([^\"]+)\"" "\\1" "LOW_LEVEL_TESTS" "${LOW_LEVEL_TESTS}")
|
|
|
|
list(REMOVE_DUPLICATES LOW_LEVEL_TESTS)
|
2021-03-15 17:42:53 +00:00
|
|
|
|
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
|
|
|
|
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/share && ln -sf
|
|
|
|
${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)
|
2018-01-06 12:07:12 +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
|
|
|
add_dependencies(fish_tests tests_dir funcs_dir)
|
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)
|
|
|
|
|
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),
|
|
|
|
# and the only dependency a test can have is on another test. So we make building fish and
|
|
|
|
# `fish_tests` prerequisites to our entire top-level `test` target.
|
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}
|
|
|
|
COMMAND DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
|
|
|
|
--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
|
|
|
|
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
|
|
|
function(add_test_target NAME)
|
|
|
|
add_custom_target(${NAME}
|
|
|
|
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R "^${NAME}$$"
|
|
|
|
DEPENDS fish_tests tests_buildroot_target
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2021-03-15 17:42:53 +00:00
|
|
|
foreach(LTEST ${LOW_LEVEL_TESTS})
|
|
|
|
add_test(
|
|
|
|
NAME ${LTEST}
|
|
|
|
COMMAND ${CMAKE_BINARY_DIR}/fish_tests ${LTEST}
|
2019-06-22 21:17:10 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2021-03-15 17:42:53 +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
|
|
|
add_test_target("${LTEST}")
|
2021-03-15 17:42:53 +00:00
|
|
|
endforeach(LTEST)
|
|
|
|
|
|
|
|
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}
|
|
|
|
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/tests/test.fish ${CHECK}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
|
|
|
)
|
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)
|