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

Message ID CH3PR84MB3424347735153F9E19AEE60EC5B42@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
State New
Headers
Series Run emacs tests |

Commit Message

Morgan Smith April 9, 2025, 7:01 p.m. UTC
  * gnu/packages/emacs.scm
(emacs-ert-selector): New function.
(emacs-minimal): Run tests.
(emacs-next-minimal): Run tests.
(emacs-next-minimal): Run tests.
(emacs->emacs-next): Run tests.

Change-Id: Ib5ffeae9b7f49b5f1a56d348c15ce4c4fb28f5ec
---
 gnu/packages/emacs.scm | 89 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 86 insertions(+), 3 deletions(-)
  

Comments

Liliana Marie Prikler April 9, 2025, 8:17 p.m. UTC | #1
Am Mittwoch, dem 09.04.2025 um 15:01 -0400 schrieb Morgan Smith:
> * gnu/packages/emacs.scm
> (emacs-ert-selector): New function.
> (emacs-minimal): Run tests.
> (emacs-next-minimal): Run tests.
> (emacs-next-minimal): Run tests.
> (emacs->emacs-next): Run tests.
Looks like some changes here are duplicated.

> Change-Id: Ib5ffeae9b7f49b5f1a56d348c15ce4c4fb28f5ec
> ---
>  gnu/packages/emacs.scm | 89
> ++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 86 insertions(+), 3 deletions(-)
> 
> diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
> index 9a020d89aa..fbde2bd913 100644
> --- a/gnu/packages/emacs.scm
> +++ b/gnu/packages/emacs.scm
> @@ -98,6 +98,26 @@ (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-public emacs-minimal
>    (package
>      (name "emacs-minimal")
> @@ -153,9 +173,24 @@ (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
> +                      ;; Broken tests.  This is inherited by other
> Emacs
> +                      ;; packages so test them all when changing
> this value
> +                      (string-append
> +                       "SELECTOR="
> +                       #$(emacs-ert-selector
> +                          '("esh-util-test/path/get-remote"
> +                            "esh-var-test/path-var/preserve-across-
> hosts"
> +                            "ffap-tests--c-path"
> +                            "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"
> +                            "tramp-test48-remote-load-path"))))
Can we bind this selector (or one of its supersets below) to a variable
so as to use (string-append "SELECTOR=" %selector)?  

Cheers
  

Patch

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 9a020d89aa..fbde2bd913 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -98,6 +98,26 @@  (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-public emacs-minimal
   (package
     (name "emacs-minimal")
@@ -153,9 +173,24 @@  (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
+                      ;; Broken tests.  This is inherited by other Emacs
+                      ;; packages so test them all when changing this value
+                      (string-append
+                       "SELECTOR="
+                       #$(emacs-ert-selector
+                          '("esh-util-test/path/get-remote"
+                            "esh-var-test/path-var/preserve-across-hosts"
+                            "ffap-tests--c-path"
+                            "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"
+                            "tramp-test48-remote-load-path"))))
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'enable-elogind
@@ -240,6 +275,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.
@@ -595,7 +637,27 @@  (define-public emacs-next-minimal
                         "emacs-native-comp-driver-options.patch"
                         "emacs-next-native-comp-fix-filenames.patch"
                         "emacs-native-comp-pin-packages.patch"
-                        "emacs-pgtk-super-key-fix.patch")))))))
+                        "emacs-pgtk-super-key-fix.patch"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments emacs-minimal)
+       ((#:make-flags _)
+        #~(list
+           (string-append
+            "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* (emacs->emacs-next emacs #:optional name
                             #:key (version (package-version emacs-next-minimal))
@@ -608,7 +670,28 @@  (define* (emacs->emacs-next emacs #:optional name
                                   (string-drop (package-name emacs)
                                                (string-length "emacs"))))))
     (version version)
-    (source source)))
+    (source source)
+    (arguments
+     (substitute-keyword-arguments (package-arguments emacs)
+       ((#:make-flags _)
+        #~(list
+           (string-append
+            "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"
+                 "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-next (emacs->emacs-next emacs))
 (define-public emacs-next-pgtk (emacs->emacs-next emacs-pgtk))