blob: 86ded1f8f92f5141256f642c78601d7ad2770f18 [file] [log] [blame]
aPiecek266ca762023-03-22 15:04:59 +01001source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
2
aPiecek15cc4cf2023-04-17 15:23:21 +02003set mdir "$::env(YANG_MODULES_DIR)"
4
aPiecek266ca762023-03-22 15:04:59 +01005variable ly_cleanup {
6 ly_ignore
7 ly_exit
8}
9
10test completion_hints_ietf_ip {Completion and hints for ietf-ip.yang} {
11-setup $ly_setup -cleanup $ly_cleanup -body {
aPiecek15cc4cf2023-04-17 15:23:21 +020012 ly_cmd "add $mdir/ietf-ip.yang"
aPiecek266ca762023-03-22 15:04:59 +010013
14 # completion and hint
15 ly_completion "print -f info -P " "print -f info -P /ietf-"
16
17 set hints {"/ietf-yang-schema-mount:schema-mounts" "/ietf-interfaces:interfaces" "/ietf-interfaces:interfaces-state"}
18 ly_hint "" "print -f info -P /ietf-" $hints
19
20 # double completion
21 ly_completion "i" "print -f info -P /ietf-interfaces:interfaces"
22 ly_completion "/" "print -f info -P /ietf-interfaces:interfaces/interface"
23
24 # a lot of hints
25 set hints {"/ietf-interfaces:interfaces/interface"
26 "/ietf-interfaces:interfaces/interface/name" "/ietf-interfaces:interfaces/interface/description"
27 "/ietf-interfaces:interfaces/interface/type" "/ietf-interfaces:interfaces/interface/enabled"
28 "/ietf-interfaces:interfaces/interface/link-up-down-trap-enable"
29 "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6"
30 }
31 ly_hint "" "print -f info -P /ietf-interfaces:interfaces/interface" $hints
32
33 # double tab
34 ly_completion "/i" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv"
35 ly_completion "4" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4"
36 set hints { "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled"
37 "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/forwarding" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/mtu"
38 "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/neighbor"
39 }
40 ly_hint "\t" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv" $hints
41
42 # no more completion
43 ly_completion "/e" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled "
44}}
45
aPiecek15cc4cf2023-04-17 15:23:21 +020046# Note that somehow a command is automatically sent again (\t\t replaced by \r) after the hints.
47# But that doesn't affect the test because the tests only focus on the word in the hint.
48
49test hint_data_file {Show file hints for command data} {
50-setup $ly_setup -cleanup $ly_cleanup -body {
51 ly_hint "data $mdir\t\t" "data $mdir" "modleaf.yang.*"
52}}
53
54test hint_data_format {Show print hints for command data --format} {
55-setup $ly_setup -cleanup $ly_cleanup -body {
56 ly_hint "data -f \t\t" "data -f " "xml.*"
57}}
58
59test hint_data_file_after_opt {Show file hints after option with argument} {
60-setup $ly_setup -cleanup $ly_cleanup -body {
61 ly_hint "data -f xml $mdir\t\t" "data -f xml $mdir" "modleaf.yang.*"
62}}
63
64test hint_data_file_after_opt2 {Show file hints after option without argument} {
65-setup $ly_setup -cleanup $ly_cleanup -body {
66 ly_hint "data -m $mdir\t\t" "data -m $mdir" "modleaf.yang.*"
67}}
68
aPiecek266ca762023-03-22 15:04:59 +010069cleanupTests