yanglint TEST of debug option
diff --git a/tools/lint/tests/interactive/debug.test b/tools/lint/tests/interactive/debug.test
new file mode 100644
index 0000000..d04c0f0
--- /dev/null
+++ b/tools/lint/tests/interactive/debug.test
@@ -0,0 +1,33 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
+
+set mdir $::env(YANG_MODULES_DIR)
+
+test debug_dict {Check debug message DICT} {
+-setup $ly_setup -cleanup $ly_cleanup -constraints {[ly_cmd_exists "debug"]} -body {
+ ly_cmd "verb debug"
+ ly_cmd "debug dict"
+ ly_cmd "load modleaf" "DICT"
+}}
+
+test debug_xpath {Check debug message XPATH} {
+-setup $ly_setup -cleanup $ly_cleanup -constraints {[ly_cmd_exists "debug"]} -body {
+ ly_cmd "verb debug"
+ ly_cmd "debug xpath"
+ ly_cmd "load modmust" "XPATH"
+}}
+
+test debug_dep_sets {Check debug message DEPSETS} {
+-setup $ly_setup -cleanup $ly_cleanup -constraints {[ly_cmd_exists "debug"]} -body {
+ ly_cmd "verb debug"
+ ly_cmd "debug dep-sets"
+ ly_cmd "load modleaf" "DEPSETS"
+}}
+
+test debug_depsets_xpath {Check debug message DEPSETS and XPATH} {
+-setup $ly_setup -cleanup $ly_cleanup -constraints {[ly_cmd_exists "debug"]} -body {
+ ly_cmd "verb debug"
+ ly_cmd "debug dep-sets xpath"
+ ly_cmd "load modmust" "DEPSETS.*XPATH"
+}}
+
+cleanupTests
diff --git a/tools/lint/tests/interactive/ly.tcl b/tools/lint/tests/interactive/ly.tcl
index 3fa2c82..6264b24 100644
--- a/tools/lint/tests/interactive/ly.tcl
+++ b/tools/lint/tests/interactive/ly.tcl
@@ -173,3 +173,27 @@
send "exit\r"
expect eof
}
+
+# Check if yanglint supports the specified command.
+# Parameter cmd is a command to be found.
+# Return true if command is found otherwise false.
+proc ly_cmd_exists {cmd} {
+ global prompt
+ set rc true
+ spawn $::env(YANGLINT)
+ ly_skip_warnings
+
+ send -- "help\r"
+ expect -- "help\r\n"
+
+ set failure_pattern "\r\n${prompt}$"
+ expect {
+ -re "${cmd}.*\r\n${prompt}$" {}
+ -re $failure_pattern {
+ set rc false
+ }
+ }
+
+ ly_exit
+ return $rc
+}
diff --git a/tools/lint/tests/non-interactive/debug.test b/tools/lint/tests/non-interactive/debug.test
new file mode 100644
index 0000000..4543acb
--- /dev/null
+++ b/tools/lint/tests/non-interactive/debug.test
@@ -0,0 +1,25 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}]
+
+set mdir $::env(YANG_MODULES_DIR)
+
+test debug_dict {Check debug message DICT} {
+-constraints {[ly_opt_exists "-G"]} -body {
+ ly_cmd_wrn "-V -V -G dict $mdir/modleaf.yang" "DICT"
+}}
+
+test debug_xpath {Check debug message XPATH} {
+-constraints {[ly_opt_exists "-G"]} -body {
+ ly_cmd_wrn "-V -V -G xpath $mdir/modmust.yang" "XPATH"
+}}
+
+test debug_dep_sets {Check debug message DEPSETS} {
+-constraints {[ly_opt_exists "-G"]} -body {
+ ly_cmd_wrn "-V -V -G dep-sets $mdir/modleaf.yang" "DEPSETS"
+}}
+
+test debug_depsets_xpath {Check debug message DEPSETS and XPATH} {
+-constraints {[ly_opt_exists "-G"]} -body {
+ ly_cmd_wrn "-V -V -G dep-sets,xpath $mdir/modmust.yang" "DEPSETS.*XPATH"
+}}
+
+cleanupTests
diff --git a/tools/lint/tests/non-interactive/ly.tcl b/tools/lint/tests/non-interactive/ly.tcl
index 7cdfde8..0f4268d 100644
--- a/tools/lint/tests/non-interactive/ly.tcl
+++ b/tools/lint/tests/non-interactive/ly.tcl
@@ -92,3 +92,19 @@
}
return
}
+
+# Check if yanglint supports the specified option.
+# Parameter opt is a option to be found.
+# Return true if option is found otherwise false.
+proc ly_opt_exists {opt} {
+ namespace import ly::private::*
+ lassign [ly_exec "--help"] rc msg
+ if { $rc != 0 } {
+ error "unexpected return code $rc:\n$msg\n"
+ }
+ if { [output_check $opt $msg] } {
+ return false
+ } else {
+ return true
+ }
+}