lilyp pushed a commit to branch emacs-team
in repository guix.

commit abf3750140bdbe50a1eb5a2712885689559fe2f8
Author: Liliana Marie Prikler <liliana.prik...@gmail.com>
AuthorDate: Sun Mar 2 11:48:36 2025 +0100

    build-system: emacs: Guess test framework.
    
    * guix/build/emacs-build-system (check-command): New variable.
    (check): Use it.
    * guix/build-system/emacs.scm (emacs-build)[test-command]: Set to #f.
---
 guix/build-system/emacs.scm       |  2 +-
 guix/build/emacs-build-system.scm | 35 +++++++++++++++++++++++------------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/guix/build-system/emacs.scm b/guix/build-system/emacs.scm
index 2ec08fe878..fc165c21d7 100644
--- a/guix/build-system/emacs.scm
+++ b/guix/build-system/emacs.scm
@@ -84,7 +84,7 @@
                       #:key source
                       (tests? (not (%current-target-system)))
                       (parallel-tests? #t)
-                      (test-command ''("make" "check"))
+                      (test-command #f) ; inferred in emacs-build-system
                       (phases '%standard-phases)
                       (outputs '("out"))
                       (include (quote %default-include))
diff --git a/guix/build/emacs-build-system.scm 
b/guix/build/emacs-build-system.scm
index aa083c6409..ff35547968 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -223,23 +223,34 @@ locations in the store in '.el' files."
   (let ((name (store-directory->elpa-name-version (assoc-ref outputs "out"))))
     (and=> (find-root-library-file name) write-pkg-file)))
 
-(define* (check #:key tests? (test-command '("make" "check"))
+(define (check-command test-command)
+  (cond
+   (test-command test-command)
+   ((which "buttercup") '("buttercup" "-L" "."))
+   ((which "ert-runner") '("ert-runner"))
+   ((file-exists? "Makefile") '("make" "check"))
+   (else #f)))
+
+(define* (check #:key tests? test-command
                 (parallel-tests? #t) #:allow-other-keys)
   "Run the tests by invoking TEST-COMMAND.
 
 When TEST-COMMAND uses make and PARALLEL-TESTS is #t, the tests are run in
 parallel. PARALLEL-TESTS? is ignored when using a non-make TEST-COMMAND."
-  (match-let (((test-program . args) test-command))
-    (let ((using-make? (string=? test-program "make")))
-      (if tests?
-          (apply invoke test-program
-                 `(,@args
-                   ,@(if (and using-make? parallel-tests?)
-                         `("-j" ,(number->string (parallel-job-count)))
-                         '())))
-          (begin
-            (format #t "test suite not run~%")
-            #t)))))
+  (match (and tests? (check-command test-command))
+    ((test-program . args)
+     (let ((using-make? (string=? test-program "make")))
+       (apply invoke test-program
+              `(,@args
+                ,@(if (and using-make? parallel-tests?)
+                      `("-j" ,(number->string (parallel-job-count)))
+                      '())))))
+    (#f
+     (if tests?
+         (begin
+           (display "warning: test system not found.\n")
+           (display "note: this will be an error in the future.\n"))
+         (display "test suite not run\n")))))
 
 (define* (install #:key outputs
                   (include %default-include)

Reply via email to