[bug#77681,v2,6/6] gnu: emacs: Run tests.

Message ID CH3PR84MB3424D35B894433E8EEF3C2E1C5B42@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
State New
Headers
Series None |

Commit Message

Morgan Smith April 9, 2025, 9:53 p.m. UTC
  Due to inheritance this enables tests on most of the Emacs packages.

* gnu/packages/emacs.scm:
(emacs-ert-selector): New function.
(%selector): New variable.
(emacs-minimal): Run tests.

Change-Id: Ib5ffeae9b7f49b5f1a56d348c15ce4c4fb28f5ec
---
 gnu/packages/emacs.scm | 45 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)
  

Comments

Liliana Marie Prikler April 12, 2025, 9:11 p.m. UTC | #1
Am Mittwoch, dem 09.04.2025 um 17:53 -0400 schrieb Morgan Smith:
> Due to inheritance this enables tests on most of the Emacs packages.
> 
> * gnu/packages/emacs.scm:
> (emacs-ert-selector): New function.
> (%selector): New variable.
> (emacs-minimal): Run tests.
> 
> Change-Id: Ib5ffeae9b7f49b5f1a56d348c15ce4c4fb28f5ec
> ---
Pushed to emacs-team earlier today.

Cheers
  

Patch

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 9a020d89aa..26bb0c7005 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -98,6 +98,42 @@  (define (%emacs-modules build-system)
       (srfi srfi-1)
       (ice-9 ftw))))
 
+(define* (emacs-ert-selector excluded-tests #:key run-nativecomp run-expensive run-unstable)
+  "Create an ERT selector that excludes tests."
+  (string-append
+   "(not (or "
+   (if run-nativecomp
+       ""
+       "(tag :nativecomp) ")
+   (if run-expensive
+       ""
+       "(tag :expensive-test) ")
+   (if run-unstable
+       ""
+       "(tag :unstable) ")
+   (string-join
+    (map
+     (lambda (test)
+       (string-append "\\\"" test "\\\""))
+     excluded-tests))
+   "))"))
+
+(define %selector
+  (emacs-ert-selector
+   '("bytecomp--fun-value-as-head"
+     "esh-util-test/path/get-remote"
+     "esh-var-test/path-var/preserve-across-hosts"
+     "ffap-tests--c-path"
+     "find-func-tests--locate-macro-generated-symbols"
+     "grep-tests--rgrep-abbreviate-properties-darwin"
+     "grep-tests--rgrep-abbreviate-properties-gnu-linux"
+     "grep-tests--rgrep-abbreviate-properties-windows-nt-dos-semantics"
+     "grep-tests--rgrep-abbreviate-properties-windows-nt-sh-semantics"
+     "info-xref-test-makeinfo"
+     "man-tests-find-header-file"
+     "tab-bar-tests-quit-restore-window"
+     "tramp-test48-remote-load-path")))
+
 (define-public emacs-minimal
   (package
     (name "emacs-minimal")
@@ -153,9 +189,9 @@  (define-public emacs-minimal
     (build-system gnu-build-system)
     (arguments
      (list
-      #:tests? #f                       ; no check target
       #:modules (%emacs-modules build-system)
       #:configure-flags #~(list "--with-gnutls=no" "--disable-build-details")
+      #:make-flags #~(list (string-append "SELECTOR=" #$%selector))
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'enable-elogind
@@ -240,6 +276,13 @@  (define-public emacs-minimal
               (substitute* (find-files "." "^Makefile\\.in$")
                 (("/bin/pwd")
                  "pwd"))))
+          (add-after 'unpack 'fix-tests
+            (lambda* (#:key tests? inputs #:allow-other-keys)
+              (when tests?
+                (substitute* "test/src/process-tests.el"
+                  (("/bin//sh") (search-input-file inputs "bin/sh")))
+                (substitute* "test/lisp/eshell/em-script-tests.el"
+                  (("/usr/bin/env") (search-input-file inputs "bin/env"))))))
           (add-after 'install 'install-site-start
             ;; Use 'guix-emacs' in "site-start.el", which is used autoload the
             ;; Elisp packages found in EMACSLOADPATH.