Skip to content

Commit de09cd3

Browse files
authored
Provide CMake module for registering CTest test cases (#123)
* feat: added auto-generation of a command line docs page resolves #89 [#89] * added cmake script to register tests
1 parent 7d000ba commit de09cd3

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

tests/AddPluginvalTests.cmake

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
include_guard (GLOBAL)
2+
3+
find_program (PLUGINVAL_PROGRAM pluginval DOC "pluginval executable")
4+
5+
if (NOT PLUGINVAL_PROGRAM)
6+
message (WARNING "pluginval not found!")
7+
endif ()
8+
9+
set (PLUGINVAL_STRICTNESS 10 CACHE STRING "pluginval strictness level, 1 to 10")
10+
11+
set_property (
12+
CACHE PLUGINVAL_STRICTNESS
13+
PROPERTY STRINGS
14+
1 2 3 4 5 6 7 8 9 10)
15+
16+
set (PLUGINVAL_REPEATS 0 CACHE STRING "number of times to repeat pluginval tests")
17+
18+
set (PLUGINVAL_SAMPLERATES "44100;44800;96000" CACHE STRING "samplerates to test in pluginval")
19+
20+
set (PLUGINVAL_BLOCKSIZES "1;250;512" CACHE STRING "blocksizes to test in pluginval")
21+
22+
mark_as_advanced (
23+
PLUGINVAL_PROGRAM PLUGINVAL_STRICTNESS PLUGINVAL_REPEATS
24+
PLUGINVAL_SAMPLERATES PLUGINVAL_BLOCKSIZES
25+
)
26+
27+
#
28+
29+
#[[
30+
add_pluginval_tests (
31+
pluginTarget
32+
[TEST_PREFIX <prefix>]
33+
[LOG_DIR <dir>]
34+
[NAMES_OUT <var>]
35+
)
36+
37+
TEST_PREFIX defaults to ${pluginTarget}.pluginval
38+
39+
LOG_DIR - relative paths will be evaluated relative to the current binary directory
40+
41+
NAMES_OUT can be name of a variable to be poplated with test names in calling scope
42+
]]
43+
function (add_pluginval_tests pluginTarget)
44+
45+
if (NOT TARGET "${pluginTarget}")
46+
message (
47+
FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} - target '${pluginTarget}' does not exist!"
48+
)
49+
endif ()
50+
51+
cmake_parse_arguments (ARG "" "TEST_PREFIX;LOG_DIR;NAMES_OUT" "" ${ARGN})
52+
53+
if (ARG_NAMES_OUT)
54+
unset ("${ARG_NAMES_OUT}" PARENT_SCOPE)
55+
endif ()
56+
57+
if (NOT PLUGINVAL_PROGRAM)
58+
return ()
59+
endif ()
60+
61+
if (NOT ARG_TEST_PREFIX)
62+
set (ARG_TEST_PREFIX "${pluginTarget}.pluginval")
63+
endif ()
64+
65+
list (JOIN PLUGINVAL_SAMPLERATES "," sample_rates)
66+
list (JOIN PLUGINVAL_BLOCKSIZES "," block_sizes)
67+
68+
set (test_name "${ARG_TEST_PREFIX}.VST3")
69+
70+
get_target_property (plugin_artefact "${pluginTarget}_VST3" JUCE_PLUGIN_ARTEFACT_FILE)
71+
72+
if (ARG_LOG_DIR)
73+
if (NOT IS_ABSOLUTE "${ARG_LOG_DIR}")
74+
set (ARG_LOG_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_LOG_DIR}")
75+
endif ()
76+
77+
set (log_dir_arg --output-dir "${ARG_LOG_DIR}")
78+
else ()
79+
unset (log_dir_arg)
80+
endif ()
81+
82+
add_test (NAME "${test_name}"
83+
COMMAND "${PLUGINVAL_PROGRAM}"
84+
--strictness-level "${PLUGINVAL_STRICTNESS}"
85+
--sample-rates "${sample_rates}"
86+
--block-sizes "${block_sizes}"
87+
--repeat "${PLUGINVAL_REPEATS}"
88+
--randomise
89+
--validate "${plugin_artefact}"
90+
${log_dir_arg}
91+
)
92+
93+
set_tests_properties (
94+
"${test_name}" PROPERTIES REQUIRED_FILES "${plugin_artefact}"
95+
)
96+
97+
message (VERBOSE "Added pluginval test for plugin target ${format_target}")
98+
99+
if (ARG_NAMES_OUT)
100+
set ("${ARG_NAMES_OUT}" "${test_name}" PARENT_SCOPE)
101+
endif ()
102+
103+
endfunction ()

0 commit comments

Comments
 (0)