epiphany w/ gtk4 and webkitgtk 2.38
[jackhill/guix/guix.git] / tests / build-emacs-utils.scm
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 (ice-9 regex)
27 #:use-module (srfi srfi-34)
28 #:use-module (srfi srfi-64))
29
30 (test-begin "build-emacs-utils")
31 ;; Only run the following tests if emacs is present.
32 (test-skip (if (which "emacs") 0 5))
33
34 (test-equal "emacs-batch-script: print foo from emacs"
35 "foo"
36 (emacs-batch-script '(princ "foo")))
37
38 (test-assert "emacs-batch-script: raise &emacs-batch-error on failure"
39 (guard (c ((emacs-batch-error? c)
40 ;; The error message format changed between Emacs 27 and Emacs
41 ;; 28.
42 (string-match "[Ww]rong.*argument.*numberp.*\"three\""
43 (emacs-batch-error-message c))))
44 (emacs-batch-script '(mapcar 'number-to-string (list 1 2 "three")))))
45
46 (call-with-temporary-directory
47 (lambda (directory)
48 (let ((mock-elisp-file (string-append directory "/foo.el")))
49 (call-with-output-file mock-elisp-file
50 (lambda (port)
51 (display ";;; foo --- mock emacs package -*- lexical-binding: t -*-
52
53 ;; Created: 4 Jun 2022
54 ;; Keywords: lisp test
55 ;; Version: 1.0.0
56 ;;; Commentary:
57 ;;; Code:
58 ;;; foo.el ends here
59 "
60 port)))
61 (test-equal "emacs-header-parse: fetch version"
62 "1.0.0"
63 (emacs-header-parse "version" mock-elisp-file))
64 (test-equal "emacs-header-parse: fetch keywords"
65 "lisp test"
66 (emacs-header-parse "keywords" mock-elisp-file))
67 (test-equal "emacs-header-parse: fetch nonexistent author"
68 "nil"
69 (emacs-header-parse "author" mock-elisp-file)))))
70
71 (test-end "build-emacs-utils")