yanglint TEST tcl tests work on Windows
diff --git a/tools/lint/CMakeLists.txt b/tools/lint/CMakeLists.txt
index 0fd2fad..dd052d8 100644
--- a/tools/lint/CMakeLists.txt
+++ b/tools/lint/CMakeLists.txt
@@ -64,7 +64,7 @@
add_test(NAME ${TEST_NAME} COMMAND ${WRAPPER} ${CMAKE_CURRENT_SOURCE_DIR}/tests/${ADDTEST_SCRIPT})
set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "TESTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests")
set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANG_MODULES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/modules")
- set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANGLINT=${PROJECT_BINARY_DIR}/yanglint")
+ set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "YANGLINT=${PROJECT_BINARY_DIR}")
endfunction(add_yanglint_test)
if(ENABLE_TESTS)
@@ -72,8 +72,12 @@
find_program(PATH_TCLSH NAMES tclsh)
if(NOT PATH_TCLSH)
message(WARNING "'tclsh' not found! The yanglint(1) interactive tests will not be available.")
- elseif(YANGLINT_INTERACTIVE)
- add_yanglint_test(NAME interactive VIA tclsh SCRIPT interactive/all.tcl)
- add_yanglint_test(NAME non-interactive VIA tclsh SCRIPT non-interactive/all.tcl)
+ else()
+ if(YANGLINT_INTERACTIVE)
+ add_yanglint_test(NAME interactive VIA tclsh SCRIPT interactive/all.tcl)
+ add_yanglint_test(NAME non-interactive VIA tclsh SCRIPT non-interactive/all.tcl)
+ else()
+ add_yanglint_test(NAME non-interactive VIA tclsh SCRIPT non-interactive/all.tcl)
+ endif()
endif()
endif()
diff --git a/tools/lint/tests/common.tcl b/tools/lint/tests/common.tcl
index ed60463..0cebd0d 100644
--- a/tools/lint/tests/common.tcl
+++ b/tools/lint/tests/common.tcl
@@ -5,12 +5,25 @@
# the script is not run via 'ctest' so paths must be set
set ::env(TESTS_DIR) "../"
set ::env(YANG_MODULES_DIR) "../modules"
- set ::env(YANGLINT) "../../../../build/yanglint"
+ set ::env(YANGLINT) "../../../../build"
::tcltest::testConstraint ctest false
} else {
::tcltest::testConstraint ctest true
}
+# Complete the path for yanglint. For example, on Windows, yanglint can be located in the Debug or Release subdirectory.
+# Note that Release build takes precedence over Debug.
+set conftypes {{} Release Debug E}
+foreach i $conftypes {
+ if { [file executable "$::env(YANGLINT)/$i/yanglint"] || [file executable "$::env(YANGLINT)/$i/yanglint.exe"] } {
+ append ::env(YANGLINT) "/$i/yanglint"
+ break
+ }
+}
+if { $i == "E" } {
+ error "yanglint executable not found"
+}
+
# prompt of error message
set error_prompt ">>>"
# the beginning of error message