aPiecek | 0ebc35b | 2023-06-22 14:11:58 +0200 | [diff] [blame^] | 1 | if(WIN32) |
| 2 | set(YANGLINT_INTERACTIVE OFF) |
| 3 | else() |
| 4 | set(YANGLINT_INTERACTIVE ON) |
| 5 | endif() |
| 6 | |
| 7 | function(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}") |
| 21 | endfunction(add_yanglint_test) |
| 22 | |
| 23 | if(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() |
| 36 | endif() |