blob: c1e081aa71b1f53ae4f93864db7fc15075984855 [file] [log] [blame]
aPiecek0ebc35b2023-06-22 14:11:58 +02001if(WIN32)
2 set(YANGLINT_INTERACTIVE OFF)
3else()
4 set(YANGLINT_INTERACTIVE ON)
5endif()
6
7function(add_yanglint_test)
8 cmake_parse_arguments(ADDTEST "" "NAME;VIA;SCRIPT" "" ${ARGN})
9 set(TEST_NAME yanglint_${ADDTEST_NAME})
10
11 if(${ADDTEST_VIA} STREQUAL "tclsh")
12 set(WRAPPER ${PATH_TCLSH})
13 else()
14 message(FATAL_ERROR "build: unexpected wrapper '${ADDTEST_VIA}'")
15 endif()
16
17 add_test(NAME ${TEST_NAME} COMMAND ${WRAPPER} ${CMAKE_CURRENT_SOURCE_DIR}/${ADDTEST_SCRIPT})
18 set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "TESTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
19 set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANG_MODULES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/modules")
20 set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANGLINT=${PROJECT_BINARY_DIR}")
21endfunction(add_yanglint_test)
22
23if(ENABLE_TESTS)
24 # tests of interactive mode using tclsh
25 find_program(PATH_TCLSH NAMES tclsh)
26 if(NOT PATH_TCLSH)
27 message(WARNING "'tclsh' not found! The yanglint(1) interactive tests will not be available.")
28 else()
29 if(YANGLINT_INTERACTIVE)
30 add_yanglint_test(NAME interactive VIA tclsh SCRIPT interactive/all.tcl)
31 add_yanglint_test(NAME non-interactive VIA tclsh SCRIPT non-interactive/all.tcl)
32 else()
33 add_yanglint_test(NAME non-interactive VIA tclsh SCRIPT non-interactive/all.tcl)
34 endif()
35 endif()
36endif()