yanglint TEST added tests for features
diff --git a/tools/lint/tests/interactive/feature.test b/tools/lint/tests/interactive/feature.test
index 32f14d7..84bfa8e 100644
--- a/tools/lint/tests/interactive/feature.test
+++ b/tools/lint/tests/interactive/feature.test
@@ -1,8 +1,37 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
-test feature_all {feature --all} {
+test feature_all_default {Default output of feature --all} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "feature -a" "yang:\r\n\t(none)\r\n\r\nietf-yang-schema-mount:\r\n\t(none)\r\n" -ex
}}
+test feature_all_add_module {Add module with only one feature and call feature --all} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load --feature modfeature:ftr1 modfeature"
+ ly_cmd "feature -a" "modfeature:\r\n\tftr1 \\(on\\)\r\n\tftr2 \\(off\\)"
+}}
+
+test feature_all_on {Add module with all enabled features and call feature --all} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load --feature modfeature:* modfeature"
+ ly_cmd "feature -a" "modfeature:\r\n\tftr1 \\(on\\)\r\n\tftr2 \\(on\\)"
+}}
+
+test feature_one_module {Show features for one module} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load ietf-ip"
+ ly_cmd "feature -f ietf-ip" " -F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf" -ex
+}}
+
+test feature_more_modules {Show a mix of modules with and without features} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+
+ set features " -F modfeature:ftr1,ftr2\
+-F modleaf:\
+-F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf"
+
+ ly_cmd "load ietf-ip modleaf modfeature"
+ ly_cmd "feature -f modfeature modleaf ietf-ip" $features -ex
+}}
+
cleanupTests
diff --git a/tools/lint/tests/interactive/ly.tcl b/tools/lint/tests/interactive/ly.tcl
index 623398f..8386848 100644
--- a/tools/lint/tests/interactive/ly.tcl
+++ b/tools/lint/tests/interactive/ly.tcl
@@ -8,10 +8,14 @@
set prompt "> "
# turn off dialog between expect and yanglint
log_user 0
+# setting some large terminal width
+stty columns 720
variable ly_setup {
spawn $::env(YANGLINT)
ly_skip_warnings
+ # Searchpath is set, so modules can be loaded via the 'load' command.
+ ly_cmd "searchpath $::env(YANG_MODULES_DIR)"
}
variable ly_cleanup {
diff --git a/tools/lint/tests/modules/modfeature.yang b/tools/lint/tests/modules/modfeature.yang
new file mode 100644
index 0000000..f59d4c8
--- /dev/null
+++ b/tools/lint/tests/modules/modfeature.yang
@@ -0,0 +1,7 @@
+module modfeature {
+ namespace "urn:yanglint:modfeature";
+ prefix l;
+
+ feature ftr1;
+ feature ftr2;
+}
diff --git a/tools/lint/tests/modules/modleaf.yang b/tools/lint/tests/modules/modleaf.yang
new file mode 100644
index 0000000..48ce786
--- /dev/null
+++ b/tools/lint/tests/modules/modleaf.yang
@@ -0,0 +1,8 @@
+module modleaf {
+ namespace "urn:yanglint:modleaf";
+ prefix l;
+
+ leaf lfl {
+ type uint16;
+ }
+}
diff --git a/tools/lint/tests/non-interactive/feature.test b/tools/lint/tests/non-interactive/feature.test
new file mode 100644
index 0000000..22d63c0
--- /dev/null
+++ b/tools/lint/tests/non-interactive/feature.test
@@ -0,0 +1,18 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}]
+
+set dir $env(YANG_MODULES_DIR)
+
+test feature_one_module {Show features for one module} {
+ ly_cmd "-f feature-param $dir/ietf-ip.yang" " -F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf" -ex
+} {}
+
+test feature_more_modules {Show a mix of modules with and without features} {
+
+ set features " -F modfeature:ftr1,ftr2\
+-F modleaf:\
+-F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf"
+
+ ly_cmd "-f feature-param $dir/modfeature.yang $dir/modleaf.yang $dir/ietf-ip.yang" $features -ex
+} {}
+
+cleanupTests