yanglint TEST of --yang-library-file parameter
diff --git a/tools/lint/tests/data/modconfig_ctx.xml b/tools/lint/tests/data/modconfig_ctx.xml
new file mode 100644
index 0000000..124989c
--- /dev/null
+++ b/tools/lint/tests/data/modconfig_ctx.xml
@@ -0,0 +1,13 @@
+<yang-library xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
+ <module-set>
+ <name>main-set</name>
+ <module>
+ <name>modconfig</name>
+ <namespace>urn:yanglint:modconfig</namespace>
+ </module>
+ </module-set>
+ <content-id>1</content-id>
+</yang-library>
+<modules-state xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
+ <module-set-id>1</module-set-id>
+</modules-state>
diff --git a/tools/lint/tests/data/modimp_type_ctx.xml b/tools/lint/tests/data/modimp_type_ctx.xml
new file mode 100644
index 0000000..e6d158a
--- /dev/null
+++ b/tools/lint/tests/data/modimp_type_ctx.xml
@@ -0,0 +1,13 @@
+<yang-library xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
+ <module-set>
+ <name>main-set</name>
+ <module>
+ <name>modimp-type</name>
+ <namespace>urn:yanglint:modimp-type</namespace>
+ </module>
+ </module-set>
+ <content-id>1</content-id>
+</yang-library>
+<modules-state xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
+ <module-set-id>1</module-set-id>
+</modules-state>
diff --git a/tools/lint/tests/interactive/clear.test b/tools/lint/tests/interactive/clear.test
index 7c03ca6..cac0810 100644
--- a/tools/lint/tests/interactive/clear.test
+++ b/tools/lint/tests/interactive/clear.test
@@ -1,6 +1,7 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
set mdir $::env(YANG_MODULES_DIR)
+set ddir $::env(TESTS_DIR)/data
test clear_searchpath {searchpath is also deleted} {
-setup $ly_setup -cleanup $ly_cleanup -body {
@@ -30,4 +31,23 @@
ly_cmd "list" "I ietf-yang-library"
}}
+test clear_ylf_list {apply --yang-library-file and check result by --list} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "clear -Y $ddir/modimp_type_ctx.xml"
+ ly_cmd "list" "I modimp-type.*i modtypedef"
+}}
+
+test clear_ylf_make_implemented {apply --yang-library-file and --make-implemented} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "clear -Y $ddir/modimp_type_ctx.xml -i -i"
+ ly_cmd "list" "I modimp-type.*I modtypedef"
+}}
+
+test clear_ylf_augment_ctx {Setup context by yang-library-file and augment module} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "clear -Y $ddir/modconfig_ctx.xml"
+ ly_cmd "add $mdir/modconfig-augment.yang"
+ ly_cmd "print -f tree modconfig" "mca:alf"
+}}
+
cleanupTests
diff --git a/tools/lint/tests/modules/modconfig-augment.yang b/tools/lint/tests/modules/modconfig-augment.yang
new file mode 100644
index 0000000..d94b366
--- /dev/null
+++ b/tools/lint/tests/modules/modconfig-augment.yang
@@ -0,0 +1,15 @@
+module modconfig-augment {
+ yang-version 1.1;
+ namespace "urn:yanglint:modconfig-augment";
+ prefix "mca";
+
+ import modconfig {
+ prefix mc;
+ }
+
+ augment "/mc:mcc" {
+ leaf alf {
+ type string;
+ }
+ }
+}
diff --git a/tools/lint/tests/non-interactive/yang_library_file.test b/tools/lint/tests/non-interactive/yang_library_file.test
new file mode 100644
index 0000000..0667263
--- /dev/null
+++ b/tools/lint/tests/non-interactive/yang_library_file.test
@@ -0,0 +1,14 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}]
+
+set mdir "$::env(YANG_MODULES_DIR)"
+set ddir "$::env(TESTS_DIR)/data"
+
+test ylf_list {apply --yang-library-file and check result by --list} {
+ ly_cmd "-Y $ddir/modimp_type_ctx.xml -p $mdir -l" "I modimp-type.*i modtypedef"
+} {}
+
+test ylf_make_implemented {apply --yang-library-file and --make-implemented} {
+ ly_cmd "-Y $ddir/modimp_type_ctx.xml -p $mdir -i -i -l" "I modimp-type.*I modtypedef"
+} {}
+
+cleanupTests