A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1# Copyright 2020 Olivier Croquette <ocroquette@free.fr>
2#
3# Permission is hereby granted, free of charge, to any person obtaining
4# a copy of this software and associated documentation files (the
5# "Software"), to deal in the Software without restriction, including
6# without limitation the rights to use, copy, modify, merge, publish,
7# distribute, sublicense, and/or sell copies of the Software, and to
8# permit persons to whom the Software is furnished to do so, subject to
9# the following conditions:
10#
11# The above copyright notice and this permission notice shall be
12# included in all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
15# WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
16# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21#
22# v1.2
23#
24# Latest version is available from GitHub:
25# https://github.com/ocroquette/cmake-qtest-discovery
26
27#[=======================================================================[.rst:
28QtTest
29----------
30
31This module defines functions to help use the Qt Test infrastructure.
32The main function is :command:`qtest_discover_tests`.
33
34.. command:: qtest_discover_tests
35
36 Automatically add tests with CTest by querying the compiled test executable
37 for available tests::
38
39 qtest_discover_tests(target
40 [WORKING_DIRECTORY dir]
41 [TEST_PREFIX prefix]
42 [TEST_SUFFIX suffix]
43 [PROPERTIES name1 value1...]
44 [DISCOVERY_TIMEOUT seconds])
45
46 ``qtest_discover_tests`` sets up a post-build command on the test executable
47 that generates the list of tests by parsing the output from running the test
48 with the ``-datatags`` argument. This ensures that the full list of
49 tests, including instantiations of parameterized tests, is obtained. Since
50 test discovery occurs at build time, it is not necessary to re-run CMake when
51 the list of tests changes.
52
53 The options are:
54
55 ``target``
56 Specifies the Google Test executable, which must be a known CMake
57 executable target. CMake will substitute the location of the built
58 executable when running the test.
59
60 ``WORKING_DIRECTORY dir``
61 Specifies the directory in which to run the discovered test cases. If this
62 option is not provided, the current binary directory is used.
63
64 ``TEST_PREFIX prefix``
65 Specifies a ``prefix`` to be prepended to the name of each discovered test
66 case.
67
68 ``TEST_SUFFIX suffix``
69 Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
70 every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
71 be specified.
72
73 ``PROPERTIES name1 value1...``
74 Specifies additional properties to be set on all tests discovered by this
75 invocation of ``qtest_discover_tests``. You can specify a timeout for the
76 test execution by setting the TIMEOUT property here, as supported by ctest.
77
78 ``DISCOVERY_TIMEOUT sec``
79 Specifies how long (in seconds) CMake will wait for the test to enumerate
80 available tests. If the test takes longer than this, discovery (and your
81 build) will fail. Most test executables will enumerate their tests very
82 quickly, but under some exceptional circumstances, a test may require a
83 longer timeout. The default is 5. See also the ``TIMEOUT`` option of
84 :command:`execute_process`.
85
86#]=======================================================================]
87
88function(qtest_discover_tests TARGET)
89if(NOT CMAKE_CROSSCOMPILING)
90 cmake_parse_arguments(
91 ""
92 ""
93 "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;DISCOVERY_TIMEOUT"
94 "PROPERTIES"
95 ${ARGN}
96 )
97
98 if(NOT _WORKING_DIRECTORY)
99 set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
100 endif()
101 if(NOT _DISCOVERY_TIMEOUT)
102 set(_DISCOVERY_TIMEOUT 5)
103 endif()
104
105 set(ctest_file_base "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}")
106 set(ctest_include_file "${ctest_file_base}_tests.cmake")
107 add_custom_command(TARGET ${TARGET}
108 POST_BUILD
109 COMMAND "${CMAKE_COMMAND}"
110 -D "\"TEST_EXECUTABLE:FILEPATH=$<TARGET_FILE:${TARGET}>\""
111 -D "\"CTEST_FILE:FILEPATH=${ctest_include_file}\""
112 -D "\"TEST_PROPERTIES=${_PROPERTIES}\""
113 -D "\"TEST_DISCOVERY_TIMEOUT=${_DISCOVERY_TIMEOUT}\""
114 -D "\"TEST_PREFIX=${_TEST_PREFIX}\""
115 -D "\"TEST_SUFFIX=${_TEST_SUFFIX}\""
116 -D "\"TEST_WORKING_DIR=${_WORKING_DIRECTORY}\""
117 -P "\"${_QTTEST_DISCOVER_TESTS_SCRIPT}\""
118 BYPRODUCTS "${ctest_include_file}"
119 )
120
121 set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
122 "${ctest_include_file}"
123 )
124else()
125 message("-- Cross compiling, discovering unit tests disabled.")
126endif()
127endfunction()
128
129
130###############################################################################
131
132set(_QTTEST_DISCOVER_TESTS_SCRIPT
133 ${CMAKE_CURRENT_LIST_DIR}/QtTestAddTests.cmake
134)