aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt25
-rwxr-xr-xtests/runtests.pl23
-rw-r--r--tests/unit/CMakeLists.txt15
3 files changed, 48 insertions, 15 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")
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 33334a751..4eac05f90 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -56,8 +56,14 @@
# These should be the only variables that might be needed to get edited:
BEGIN {
- push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
- push(@INC, ".");
+ # Define srcdir to the location of the tests source directory. This is
+ # usually set by the Makefile, but for out-of-tree builds with direct
+ # invocation of runtests.pl, it may not be set.
+ if(!defined $ENV{'srcdir'}) {
+ use File::Basename;
+ $ENV{'srcdir'} = dirname(__FILE__);
+ }
+ push(@INC, $ENV{'srcdir'});
# run time statistics needs Time::HiRes
eval {
no warnings "all";
@@ -559,7 +565,11 @@ sub checkcmd {
#
my $disttests;
sub get_disttests {
- my @dist = `cd data && make show`;
+ my $makeCmd = 'make';
+ if(-f "../CMakeCache.txt") {
+ $makeCmd = 'cmake --build ../.. --target';
+ }
+ my @dist = `cd data && $makeCmd show`;
$disttests = join("", @dist);
}
@@ -5120,6 +5130,13 @@ disabledtests("$TESTDIR/DISABLED.local");
# Check options to this test program
#
+# Special case for CMake: replace '${TFLAGS}' by the contents of the
+# environment variable (if any).
+if(@ARGV && $ARGV[-1] eq '${TFLAGS}') {
+ pop @ARGV;
+ push(@ARGV, split(' ', $ENV{'TFLAGS'})) if defined($ENV{'TFLAGS'});
+}
+
my $number=0;
my $fromnum=-1;
my @testthis;
diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt
index a18ea18e0..e5c4127a0 100644
--- a/tests/unit/CMakeLists.txt
+++ b/tests/unit/CMakeLists.txt
@@ -20,6 +20,9 @@
#
###########################################################################
+# TODO build a special libcurlu library for unittests.
+return()
+
set(UT_SRC
unit1300.c
unit1301.c
@@ -63,16 +66,4 @@ foreach(_testfile ${UT_SRC})
target_link_libraries(${_testname} libcurl ${CURL_LIBS})
set_target_properties(${_testname}
PROPERTIES COMPILE_DEFINITIONS "UNITTESTS")
-
- if(HIDES_CURL_PRIVATE_SYMBOLS)
- set_target_properties(${_testname}
- PROPERTIES
- EXCLUDE_FROM_ALL TRUE
- EXCLUDE_FROM_DEFAULT_BUILD TRUE
- )
- else()
- add_test(NAME ${_testname}
- COMMAND ${_testname} "http://www.google.com"
- )
- endif()
endforeach()