summaryrefslogtreecommitdiffstats
path: root/tests/yanglint/interactive/completion.test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
commit16527d165de55f2727f55b752b30d44a7e61e927 (patch)
tree0840ee6e0e109a9e85f0d80ff36f92587c6a5538 /tests/yanglint/interactive/completion.test
parentReleasing progress-linux version 2.1.30-2.1~progress7.99u1. (diff)
downloadlibyang2-16527d165de55f2727f55b752b30d44a7e61e927.tar.xz
libyang2-16527d165de55f2727f55b752b30d44a7e61e927.zip
Merging upstream version 2.1.148.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/yanglint/interactive/completion.test')
-rw-r--r--tests/yanglint/interactive/completion.test69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/yanglint/interactive/completion.test b/tests/yanglint/interactive/completion.test
new file mode 100644
index 0000000..86ded1f
--- /dev/null
+++ b/tests/yanglint/interactive/completion.test
@@ -0,0 +1,69 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
+
+set mdir "$::env(YANG_MODULES_DIR)"
+
+variable ly_cleanup {
+ ly_ignore
+ ly_exit
+}
+
+test completion_hints_ietf_ip {Completion and hints for ietf-ip.yang} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "add $mdir/ietf-ip.yang"
+
+ # completion and hint
+ ly_completion "print -f info -P " "print -f info -P /ietf-"
+
+ set hints {"/ietf-yang-schema-mount:schema-mounts" "/ietf-interfaces:interfaces" "/ietf-interfaces:interfaces-state"}
+ ly_hint "" "print -f info -P /ietf-" $hints
+
+ # double completion
+ ly_completion "i" "print -f info -P /ietf-interfaces:interfaces"
+ ly_completion "/" "print -f info -P /ietf-interfaces:interfaces/interface"
+
+ # a lot of hints
+ set hints {"/ietf-interfaces:interfaces/interface"
+ "/ietf-interfaces:interfaces/interface/name" "/ietf-interfaces:interfaces/interface/description"
+ "/ietf-interfaces:interfaces/interface/type" "/ietf-interfaces:interfaces/interface/enabled"
+ "/ietf-interfaces:interfaces/interface/link-up-down-trap-enable"
+ "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6"
+ }
+ ly_hint "" "print -f info -P /ietf-interfaces:interfaces/interface" $hints
+
+ # double tab
+ ly_completion "/i" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv"
+ ly_completion "4" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4"
+ set hints { "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled"
+ "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/forwarding" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/mtu"
+ "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/neighbor"
+ }
+ ly_hint "\t" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv" $hints
+
+ # no more completion
+ ly_completion "/e" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled "
+}}
+
+# Note that somehow a command is automatically sent again (\t\t replaced by \r) after the hints.
+# But that doesn't affect the test because the tests only focus on the word in the hint.
+
+test hint_data_file {Show file hints for command data} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data $mdir\t\t" "data $mdir" "modleaf.yang.*"
+}}
+
+test hint_data_format {Show print hints for command data --format} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data -f \t\t" "data -f " "xml.*"
+}}
+
+test hint_data_file_after_opt {Show file hints after option with argument} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data -f xml $mdir\t\t" "data -f xml $mdir" "modleaf.yang.*"
+}}
+
+test hint_data_file_after_opt2 {Show file hints after option without argument} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data -m $mdir\t\t" "data -m $mdir" "modleaf.yang.*"
+}}
+
+cleanupTests