yanglint TEST printing of submodule
diff --git a/tools/lint/tests/interactive/print.test b/tools/lint/tests/interactive/print.test
index eb36835..8b9d740 100644
--- a/tools/lint/tests/interactive/print.test
+++ b/tools/lint/tests/interactive/print.test
@@ -8,12 +8,24 @@
ly_cmd "print -f yang modleaf" "leaf lfl"
}}
+test print_yang_submodule {Print submodule in yang format} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load modinclude"
+ ly_cmd "print -f yang modsub" "submodule modsub"
+}}
+
test print_yin {} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load modleaf"
ly_cmd "print -f yin modleaf" "<leaf name=\"lfl\">"
}}
+test print_yin_submodule {Print submodule in yin format} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load modinclude"
+ ly_cmd "print -f yin modsub" "<submodule name=\"modsub\""
+}}
+
test print_info {} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load modleaf"
@@ -38,6 +50,12 @@
ly_cmd "print -f tree modleaf" "\\+--rw lfl"
}}
+test print_tree_submodule {Print submodule in tree format} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load modinclude"
+ ly_cmd "print -f tree modsub" "submodule: modsub"
+}}
+
test print_tree_path {Print subtree in tree format} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load ietf-ip"
diff --git a/tools/lint/tests/modules/modinclude.yang b/tools/lint/tests/modules/modinclude.yang
new file mode 100644
index 0000000..849d43f
--- /dev/null
+++ b/tools/lint/tests/modules/modinclude.yang
@@ -0,0 +1,9 @@
+module modinclude {
+ yang-version 1.1;
+ namespace "urn:yanglint:modinclude";
+ prefix mi;
+
+ include "modsub";
+
+ container mic;
+}
diff --git a/tools/lint/tests/modules/modsub.yang b/tools/lint/tests/modules/modsub.yang
new file mode 100644
index 0000000..79d9286
--- /dev/null
+++ b/tools/lint/tests/modules/modsub.yang
@@ -0,0 +1,8 @@
+submodule modsub {
+ yang-version 1.1;
+ belongs-to modinclude {
+ prefix mi;
+ }
+
+ container msc;
+}
diff --git a/tools/lint/tests/non-interactive/format.test b/tools/lint/tests/non-interactive/format.test
index 303a7b0..5c23ddb 100644
--- a/tools/lint/tests/non-interactive/format.test
+++ b/tools/lint/tests/non-interactive/format.test
@@ -7,10 +7,18 @@
ly_cmd "-f yang $mdir/modleaf.yang" "leaf lfl"
} {}
+test format_yang_submodule {Print submodule in yang format} {
+ ly_cmd "-s modsub -f yang $mdir/modinclude.yang" "submodule modsub"
+} {}
+
test format_yin {} {
ly_cmd "-f yin $mdir/modleaf.yang" "<leaf name=\"lfl\">"
} {}
+test format_yin_submodule {Print submodule in yin format} {
+ ly_cmd "-s modsub -f yin $mdir/modinclude.yang" "<submodule name=\"modsub\""
+} {}
+
test format_info {} {
ly_cmd "-f info $mdir/modleaf.yang" "status current"
} {}
@@ -19,6 +27,10 @@
ly_cmd "-f tree $mdir/modleaf.yang" "\\+--rw lfl"
} {}
+test format_tree_submodule {Print submodule in tree format} {
+ ly_cmd "-s modsub -f tree $mdir/modinclude.yang" "submodule: modsub"
+} {}
+
test format_tree_path {Print subtree in tree format} {
ly_cmd "-f tree -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address.*\\+--rw prefix-length"
} {}