summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFredrik Salomonsson <plattfot@posteo.net>2022-06-05 19:51:43 +0000
committerLudovic Courtès <ludo@gnu.org>2022-06-17 23:39:32 +0200
commitc3afbd05bf541b31b122e6093ff10eabf6a47926 (patch)
tree8aeb015115df87b97f4a02459bcc4d0715d322b2 /tests
parentf8275916fc6fcb3dd9bd8ef7dc4ddce2dca98c7d (diff)
downloadguix-c3afbd05bf541b31b122e6093ff10eabf6a47926.tar.gz
guix-c3afbd05bf541b31b122e6093ff10eabf6a47926.tar.xz
guix: emacs-utils: Add emacs-header-parse.
* guix/build/emacs-utils.scm (emacs-header-parse): New procedure. * tests/build-emacs-utils.scm ("emacs-header-parse: fetch version", "emacs-header-parse: fetch keywords", "emacs-header-parse: fetch nonexistent author"): New tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/build-emacs-utils.scm27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/build-emacs-utils.scm b/tests/build-emacs-utils.scm
index 27cff46c38..081032285a 100644
--- a/tests/build-emacs-utils.scm
+++ b/tests/build-emacs-utils.scm
@@ -28,7 +28,7 @@
(test-begin "build-emacs-utils")
;; Only run the following tests if emacs is present.
-(test-skip (if (which "emacs") 0 2))
+(test-skip (if (which "emacs") 0 5))
(test-equal "emacs-batch-script: print foo from emacs"
"foo"
@@ -40,4 +40,29 @@
"Lisp error: (wrong-type-argument numberp \"three\")")))
(emacs-batch-script '(mapcar 'number-to-string (list 1 2 "three")))))
+(call-with-temporary-directory
+ (lambda (directory)
+ (let ((mock-elisp-file (string-append directory "/foo.el")))
+ (call-with-output-file mock-elisp-file
+ (lambda (port)
+ (display ";;; foo --- mock emacs package -*- lexical-binding: t -*-
+
+;; Created: 4 Jun 2022
+;; Keywords: lisp test
+;; Version: 1.0.0
+;;; Commentary:
+;;; Code:
+;;; foo.el ends here
+"
+ port)))
+ (test-equal "emacs-header-parse: fetch version"
+ "1.0.0"
+ (emacs-header-parse "version" mock-elisp-file))
+ (test-equal "emacs-header-parse: fetch keywords"
+ "lisp test"
+ (emacs-header-parse "keywords" mock-elisp-file))
+ (test-equal "emacs-header-parse: fetch nonexistent author"
+ "nil"
+ (emacs-header-parse "author" mock-elisp-file)))))
+
(test-end "build-emacs-utils")