aboutsummaryrefslogtreecommitdiff
path: root/tests/CMakeLists.txt
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2020-05-10 02:12:12 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-05-12 08:50:17 +0200
commitad6416986755e417c66e2c646d532561b445a5b5 (patch)
tree88a3b56f838cdefd14f6a21bd22b10e0a25a0b1f /tests/CMakeLists.txt
parentc2ab2494ef375bfc5d621b39badabeb9a0c86f6a (diff)
CMake: fix runtests.pl with CMake, add new test targets
* runtests.pl: - Fix out-of-tree build under CMake when srcdir is not set. Default srcdir to the location of runtests.pl. - Add a hack to allow CMake to use the TFLAGS option as documented in tests/README and used in scripts/travis/script.sh. * Bump CMake version to 3.2 for USES_TERMINAL, dropping Debian Jessie support (no one should care, it is already EOL.). * Remove CTest since it defines its own 'test' target with no tests since all unittests are already broken and not built by default. * Add new test targets based on the options from Makefile.am. Since new test targets are rarely added, I opted for duplicating the runtests.pl options as opposed to creating a new Makefile.inc file. Use top-level target names (test-x) instead of x-test since that is used by CI and others. Closes #5358
Diffstat (limited to 'tests/CMakeLists.txt')
-rw-r--r--tests/CMakeLists.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index caba3c86a..60ce5c262 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -24,3 +24,28 @@ add_subdirectory(data)
add_subdirectory(libtest)
add_subdirectory(server)
add_subdirectory(unit)
+
+function(add_runtests targetname test_flags)
+ # Use a special '${TFLAGS}' placeholder as last argument which will be
+ # replaced by the contents of the environment variable in runtests.pl.
+ # This is a workaround for CMake's limitation where commands executed by
+ # 'make' or 'ninja' cannot portably reference environment variables.
+ string(REPLACE " " ";" test_flags_list "${test_flags}")
+ add_custom_target(${targetname}
+ COMMAND
+ "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
+ ${test_flags_list}
+ "\${TFLAGS}"
+ DEPENDS testdeps
+ VERBATIM USES_TERMINAL
+ )
+endfunction()
+
+add_runtests(test "")
+add_runtests(test-quiet "-a -s")
+add_runtests(test-am "-a -am")
+add_runtests(test-full "-a -p -r")
+# !flaky means that it'll skip all tests using the flaky keyword
+add_runtests(test-nonflaky "-a -p !flaky")
+add_runtests(test-torture "-a -t")
+add_runtests(test-event "-a -e")