| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 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 | |
| 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 | |
| 41 | |
| 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")
|