summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2024-10-23 19:27:37 +0200
committerUlrich Müller <ulm@gentoo.org>2024-10-23 19:27:37 +0200
commit598347e136c174ed5dba6f37f5b48c198c343c54 (patch)
treee40f95753bb7e0c7af297b7d08e79be52463f93f
parentAvoid e as variable name (diff)
downloadebuild-mode-598347e136c174ed5dba6f37f5b48c198c343c54.tar.gz
ebuild-mode-598347e136c174ed5dba6f37f5b48c198c343c54.tar.bz2
ebuild-mode-598347e136c174ed5dba6f37f5b48c198c343c54.zip
New test for devbook-locate-schema-file
* devbook-mode.el (devbook-locate-schema-file): Be less verbose if noninteractive. * test/devbook-mode-tests.el (devbook-mode-test-locate-schema): New test. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ChangeLog7
-rw-r--r--devbook-mode.el2
-rw-r--r--test/devbook-mode-tests.el19
3 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 87c803e..483b592 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-10-23 Ulrich Müller <ulm@gentoo.org>
+
+ * devbook-mode.el (devbook-locate-schema-file): Be less verbose
+ if noninteractive.
+ * test/devbook-mode-tests.el (devbook-mode-test-locate-schema):
+ New test.
+
2024-10-14 Ulrich Müller <ulm@gentoo.org>
* ebuild-mode.el:
diff --git a/devbook-mode.el b/devbook-mode.el
index 622f2ac..e4a3bea 100644
--- a/devbook-mode.el
+++ b/devbook-mode.el
@@ -44,7 +44,7 @@ NOERROR is non-nil."
(condition-case err
(progn
(rng-set-schema-file-1 file)
- (rng-what-schema))
+ (unless noninteractive (rng-what-schema)))
(error (unless noerror (signal (car err) (cdr err))))))
(noerror nil)
(t (error "Schema file %s not found" devbook-schema-file-name)))))
diff --git a/test/devbook-mode-tests.el b/test/devbook-mode-tests.el
index 321e1e6..37edc8b 100644
--- a/test/devbook-mode-tests.el
+++ b/test/devbook-mode-tests.el
@@ -31,6 +31,25 @@
(defun devbook-mode-test-input (&rest _args)
(concat (pop devbook-mode-test-input)))
+(ert-deftest devbook-mode-test-locate-schema ()
+ (cl-letf* ((rncfile "/home/larry/devmanual/devbook.rnc")
+ ((symbol-function 'file-exists-p)
+ (lambda (file) (string-equal file rncfile)))
+ ((symbol-function 'file-directory-p)
+ (lambda (_file) t))
+ ((symbol-function 'insert-file-contents)
+ (lambda (file &rest _args)
+ (unless (string-equal file rncfile)
+ (signal 'file-missing nil))
+ (insert "start = element foo { empty }\n"))))
+ (let ((buffer-file-name "/home/larry/devmanual/quickstart/text.xml"))
+ (devbook-locate-schema-file)
+ (should (equal rng-current-schema-file-name rncfile)))
+ (let ((buffer-file-name "/home/larry/elsewhere/text.xml"))
+ (should (equal
+ (should-error (devbook-locate-schema-file))
+ '(error "Schema file devbook.rnc not found"))))))
+
(ert-deftest devbook-mode-test-skeleton ()
(with-temp-buffer
(cl-letf (((symbol-function 'read-from-minibuffer)