gnu: emacs-hyperbole: Improve package style.
[jackhill/guix/guix.git] / tests / build-emacs-utils.scm
CommitLineData
f8275916
FS
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2022 Fredrik Salomonsson <plattfot@posteo.net>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19
20(define-module (test build-emacs-utils)
21 #:use-module (guix tests)
22 #:use-module (guix build emacs-utils)
23 #:use-module (guix build utils)
24 #:use-module ((guix utils)
25 #:select (call-with-temporary-directory))
26 #:use-module (srfi srfi-34)
27 #:use-module (srfi srfi-64))
28
29(test-begin "build-emacs-utils")
30;; Only run the following tests if emacs is present.
c3afbd05 31(test-skip (if (which "emacs") 0 5))
f8275916
FS
32
33(test-equal "emacs-batch-script: print foo from emacs"
34 "foo"
35 (emacs-batch-script '(princ "foo")))
36
37(test-assert "emacs-batch-script: raise &emacs-batch-error on failure"
38 (guard (c ((emacs-batch-error? c)
39 (string-contains (emacs-batch-error-message c)
40 "Lisp error: (wrong-type-argument numberp \"three\")")))
41 (emacs-batch-script '(mapcar 'number-to-string (list 1 2 "three")))))
42
c3afbd05
FS
43(call-with-temporary-directory
44 (lambda (directory)
45 (let ((mock-elisp-file (string-append directory "/foo.el")))
46 (call-with-output-file mock-elisp-file
47 (lambda (port)
48 (display ";;; foo --- mock emacs package -*- lexical-binding: t -*-
49
50;; Created: 4 Jun 2022
51;; Keywords: lisp test
52;; Version: 1.0.0
53;;; Commentary:
54;;; Code:
55;;; foo.el ends here
56"
57 port)))
58 (test-equal "emacs-header-parse: fetch version"
59 "1.0.0"
60 (emacs-header-parse "version" mock-elisp-file))
61 (test-equal "emacs-header-parse: fetch keywords"
62 "lisp test"
63 (emacs-header-parse "keywords" mock-elisp-file))
64 (test-equal "emacs-header-parse: fetch nonexistent author"
65 "nil"
66 (emacs-header-parse "author" mock-elisp-file)))))
67
f8275916 68(test-end "build-emacs-utils")