1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.haxx.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21###########################################################################
22add_custom_target(testdeps)
23add_subdirectory(data)
24add_subdirectory(libtest)
25add_subdirectory(server)
26add_subdirectory(unit)
27
28function(add_runtests targetname test_flags)
29  # Use a special '$TFLAGS' placeholder as last argument which will be
30  # replaced by the contents of the environment variable in runtests.pl.
31  # This is a workaround for CMake's limitation where commands executed by
32  # 'make' or 'ninja' cannot portably reference environment variables.
33  string(REPLACE " " ";" test_flags_list "${test_flags}")
34  add_custom_target(${targetname}
35    COMMAND
36      "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
37      ${test_flags_list}
38      "\$TFLAGS"
39    DEPENDS testdeps
40    VERBATIM USES_TERMINAL
41  )
42endfunction()
43
44add_runtests(test           "")
45add_runtests(test-quiet     "-a -s")
46add_runtests(test-am        "-a -am")
47add_runtests(test-full      "-a -p -r")
48# !flaky means that it'll skip all tests using the flaky keyword
49add_runtests(test-nonflaky  "-a -p !flaky")
50add_runtests(test-torture   "-a -t")
51add_runtests(test-event     "-a -e")
52