diff options
| author | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2024-07-19 09:35:34 +0200 |
|---|---|---|
| committer | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2024-07-21 09:42:13 +0200 |
| commit | f8364fabbd1dd9b3cfd098ddf8ea13b29c066866 (patch) | |
| tree | cfcbf3a6727c5aab7cf45a14835cbe7086f6a7a2 /gnu/tests/emacs.scm | |
| parent | f999a240a19257f6cfbe4e4928cbface1263a266 (diff) | |
gnu: Add system test for Emacs.
* gnu/tests/emacs.scm: New file.
Diffstat (limited to 'gnu/tests/emacs.scm')
| -rw-r--r-- | gnu/tests/emacs.scm | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/gnu/tests/emacs.scm b/gnu/tests/emacs.scm new file mode 100644 index 00000000000..f15eec70dbe --- /dev/null +++ b/gnu/tests/emacs.scm | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2024 Liliana Marie Prikler <liliana.prikler@gmail.com> | ||
| 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 | (define-module (gnu tests emacs) | ||
| 20 | #:use-module (gnu tests) | ||
| 21 | #:use-module (gnu packages emacs) | ||
| 22 | #:use-module (gnu packages vim) | ||
| 23 | #:use-module (gnu services) | ||
| 24 | #:use-module (gnu system) | ||
| 25 | #:use-module (gnu system vm) | ||
| 26 | #:use-module (guix packages) | ||
| 27 | #:use-module (guix gexp) | ||
| 28 | #:use-module (srfi srfi-1) | ||
| 29 | #:export (%test-emacs-native-comp-replacable)) | ||
| 30 | |||
| 31 | (define (run-native-comp-replacable-test old-emacs new-emacs) | ||
| 32 | (define vm (virtual-machine (marionette-operating-system %simple-os))) | ||
| 33 | |||
| 34 | (define test | ||
| 35 | (with-imported-modules '((gnu build marionette)) | ||
| 36 | #~(begin | ||
| 37 | (use-modules (gnu build marionette) | ||
| 38 | (srfi srfi-1) | ||
| 39 | (srfi srfi-64)) | ||
| 40 | |||
| 41 | (define marionette (make-marionette (list #$vm))) | ||
| 42 | (define (marionette-emacs-eval emacs code) | ||
| 43 | (marionette-eval | ||
| 44 | `(begin | ||
| 45 | (use-modules (ice-9 rdelim) (ice-9 popen)) | ||
| 46 | (read-line | ||
| 47 | (open-pipe* | ||
| 48 | OPEN_READ | ||
| 49 | ,emacs "--batch" | ||
| 50 | ,(string-append "--eval=" code)))) | ||
| 51 | marionette)) | ||
| 52 | |||
| 53 | (define (emacs-native-comp-dir emacs) | ||
| 54 | (marionette-emacs-eval emacs "(princ comp-native-version-dir)")) | ||
| 55 | (define (emacs-abi-hash emacs) | ||
| 56 | (marionette-emacs-eval emacs "(princ comp-abi-hash)")) | ||
| 57 | (define (emacs-effective-version emacs) | ||
| 58 | (marionette-emacs-eval | ||
| 59 | emacs | ||
| 60 | "(princ | ||
| 61 | (format \"%s.%s\" emacs-major-version emacs-minor-version))")) | ||
| 62 | |||
| 63 | (define old-emacs-bin #$(file-append old-emacs "/bin/emacs")) | ||
| 64 | (define new-emacs-bin #$(file-append new-emacs "/bin/emacs")) | ||
| 65 | |||
| 66 | (test-runner-current (system-test-runner #$output)) | ||
| 67 | (test-begin "emacs-native-comp-replacable") | ||
| 68 | (test-equal "comp-abi-hash" | ||
| 69 | (emacs-abi-hash old-emacs-bin) | ||
| 70 | (emacs-abi-hash new-emacs-bin)) | ||
| 71 | (test-equal "native-comp-dir" | ||
| 72 | (emacs-native-comp-dir old-emacs-bin) | ||
| 73 | (emacs-native-comp-dir new-emacs-bin)) | ||
| 74 | (test-assert "old emacs has hierarchical layout" | ||
| 75 | (file-exists? | ||
| 76 | (string-append #$old-emacs "/lib/emacs/" | ||
| 77 | (emacs-effective-version old-emacs-bin) | ||
| 78 | "/native-lisp/" | ||
| 79 | (emacs-native-comp-dir old-emacs-bin) | ||
| 80 | "/preloaded/emacs-lisp/comp.eln"))) | ||
| 81 | (test-assert "new emacs has hierarchical layout" | ||
| 82 | (file-exists? | ||
| 83 | (string-append #$new-emacs "/lib/emacs/" | ||
| 84 | (emacs-effective-version new-emacs-bin) | ||
| 85 | "/native-lisp/" | ||
| 86 | (emacs-native-comp-dir new-emacs-bin) | ||
| 87 | "/preloaded/emacs-lisp/comp.eln"))) | ||
| 88 | (test-end)))) | ||
| 89 | |||
| 90 | (gexp->derivation "emacs-native-comp-compatible" test)) | ||
| 91 | |||
| 92 | (define (package-without-replacement pkg) | ||
| 93 | (package (inherit pkg) (replacement #f))) | ||
| 94 | |||
| 95 | (define %test-emacs-native-comp-replacable | ||
| 96 | (system-test | ||
| 97 | (name "emacs-native-comp") | ||
| 98 | (description "Test whether an emacs replacement (if any) is valid.") | ||
| 99 | (value (run-native-comp-replacable-test | ||
| 100 | (package-without-replacement emacs) | ||
| 101 | emacs)))) | ||
