Subject: bug#56334: Should asdf-build-system/sbcl use load-system instead of compile-system?

From: Pierre Neidhardt <[email-masked]>
Date: Mon, 04 Jul 2022 21:57:42 +0200

Find the first draft attached.  Do not merge, we need to figure out what
to do with sbcl-stumpwm-kbd-layouts.
This fixes 2 flaws in the asdf-build-system:

1. Use asdf:load-system instead of asdf:compile-system.  The latter is not
recommended by the manual and fails with at least 2 systems.

2. Add the build directory to the ASDF registry so that .asd files are
automatically found.  This has a double benefit:
  - It dramatically simplifies package definition writing.
  - It fixes a bug which used to cause the check phase to fail.

All commits after the first two adapt the Common Lisp package definitions to
the new build system and in particular fix many check phases.
>From fd4eb6c4d5fce8d3c1ef205b541ddf76ed0c478a Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Fri, 1 Jul 2022 16:37:44 +0200
Subject: [PATCH 01/18] guix: build: Switch from asdf:compile-system to
 asdf:load-system.

* guix/build/lisp-utils.scm (compile-systems): Switch from asdf:compile-system
to asdf:load-system.

According to the ASDF manual:

This will make sure all the files in the system are compiled, but not
necessarily load any of them in the current image; on most systems, it
will _not_ load all compiled files in the current image.  This function
exists for symmetry with 'load-system' but is not recommended unless you
are writing build scripts and know what you're doing.
---
 guix/build/lisp-utils.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm
index 17d2637f87..bd6b21d5a6 100644
--- a/guix/build/lisp-utils.scm
+++ b/guix/build/lisp-utils.scm
@@ -116,7 +116,7 @@ (define (compile-systems systems asd-files)
               `(asdf:load-asd (truename ,asd-file)))
             asd-files)
      ,@(map (lambda (system)
-              `(asdf:compile-system ,system))
+              `(asdf:load-system ,system))
             systems))))
 
 (define (test-system system asd-files test-asd-file)
-- 
2.32.0

>From 2395f5bef855cb734d13745b9c90a3bbae550d56 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Fri, 1 Jul 2022 17:17:32 +0200
Subject: [PATCH 02/18] build-system: asdf: Let ASDF locate the .asd files.

* guix/build-system/asdf.scm (package-with-build-system): Remove 'asd-files'
and replace 'test-asd-file' by 'asd-test-systems'.
(lower): Same.

* guix/build/asdf-build-system.scm (source-asd-file): Remove since ASDF does
it better than us.
(find-asd-files): Same.
(build): Remove unused asd-files argument.
(check): Remove asd-files argument and replace asd-systems by
asd-test-systems.

* guix/build/lisp-utils.scm (compile-systems): Call to ASDF to find the
systems.
(test-system): Same.

This approach has many benefits:

- It's simplifies the build system.
- The package definitions are easier to write.
- It fixes a bug with systems that call asdf:clear-system which would cause
  the load to fail.  See for instance test systems using Prove.
---
 guix/build-system/asdf.scm       | 13 +++++++-----
 guix/build/asdf-build-system.scm | 28 ++++++-------------------
 guix/build/lisp-utils.scm        | 35 ++++++++++++++------------------
 3 files changed, 29 insertions(+), 47 deletions(-)

diff --git a/guix/build-system/asdf.scm b/guix/build-system/asdf.scm
index a0f4634db0..98231714d9 100644
--- a/guix/build-system/asdf.scm
+++ b/guix/build-system/asdf.scm
@@ -202,7 +202,7 @@ (define (new-inputs inputs-getter)
       (define base-arguments
         (if target-is-source?
             (strip-keyword-arguments
-             '(#:tests? #:asd-files #:lisp #:asd-systems #:test-asd-file)
+             '(#:tests? #:lisp #:asd-systems #:asd-test-systems)
              (package-arguments pkg))
             (package-arguments pkg)))
 
@@ -270,9 +270,8 @@ (define (asdf-build lisp-type)
   (lambda* (name inputs
                  #:key source outputs
                  (tests? #t)
-                 (asd-files ''())
                  (asd-systems ''())
-                 (test-asd-file #f)
+                 (asd-test-systems ''())
                  (phases '%standard-phases)
                  (search-paths '())
                  (system (%current-system))
@@ -292,6 +291,11 @@ (define systems
             `(quote ,(list package-name)))
           asd-systems))
 
+    (define test-systems
+      (if (null? (cadr asd-test-systems))
+          systems
+          asd-test-systems))
+
     (define builder
       (with-imported-modules imported-modules
         #~(begin
@@ -302,9 +306,8 @@ (define builder
                            (%lisp-type #$lisp-type))
               (asdf-build #:name #$name
                           #:source #+source
-                          #:asd-files #$asd-files
                           #:asd-systems #$systems
-                          #:test-asd-file #$test-asd-file
+                          #:asd-test-systems #$test-systems
                           #:system #$system
                           #:tests? #$tests?
                           #:phases #$phases
diff --git a/guix/build/asdf-build-system.scm b/guix/build/asdf-build-system.scm
index 6186613e52..2cce72c5c1 100644
--- a/guix/build/asdf-build-system.scm
+++ b/guix/build/asdf-build-system.scm
@@ -78,16 +78,6 @@ (define (output-translation source-path
     (,(library-directory object-output)
      :**/ :*.*.*)))
 
-(define (source-asd-file output name asd-file)
-  (string-append (lisp-source-directory output name) "/" asd-file))
-
-(define (find-asd-files output name asd-files)
-  (if (null? asd-files)
-      (find-files (lisp-source-directory output name) "\\.asd$")
-      (map (lambda (asd-file)
-             (source-asd-file output name asd-file))
-           asd-files)))
-
 (define (copy-files-to-output out name)
   "Copy all files from the current directory to OUT.  Create an extra link to
 any system-defining files in the source to a convenient location.  This is
@@ -190,7 +180,7 @@ (define* (configure #:key inputs #:allow-other-keys)
     (setenv "XDG_CONFIG_DIRS" (string-append out "/etc")))
   #t)
 
-(define* (build #:key outputs inputs asd-files asd-systems
+(define* (build #:key outputs inputs asd-systems
                 #:allow-other-keys)
   "Compile the system."
   (let* ((out (library-output outputs))
@@ -198,26 +188,20 @@ (define* (build #:key outputs inputs asd-files asd-systems
          (source-path (string-append out (%lisp-source-install-prefix)))
          (translations (wrap-output-translations
                         `(,(output-translation source-path
-                                               out))))
-         (asd-files (find-asd-files out system-name asd-files)))
+                                               out)))))
     (setenv "ASDF_OUTPUT_TRANSLATIONS"
             (replace-escaped-macros (format #f "~S" translations)))
     (setenv "HOME" out) ; ecl's asdf sometimes wants to create $HOME/.cache
-    (compile-systems asd-systems asd-files))
+    (compile-systems asd-systems (lisp-source-directory out system-name)))
   #t)
 
-(define* (check #:key tests? outputs inputs asd-files asd-systems
-                test-asd-file
+(define* (check #:key tests? outputs inputs asd-test-systems
                 #:allow-other-keys)
   "Test the system."
   (let* ((out (library-output outputs))
-         (system-name (main-system-name out))
-         (asd-files (find-asd-files out system-name asd-files))
-         (test-asd-file
-          (and=> test-asd-file
-                 (cut source-asd-file out system-name <>))))
+         (system-name (main-system-name out)))
     (if tests?
-        (test-system (first asd-systems) asd-files test-asd-file)
+        (test-system asd-test-systems (lisp-source-directory out system-name))
         (format #t "test suite not run~%")))
   #t)
 
diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm
index bd6b21d5a6..82be117c68 100644
--- a/guix/build/lisp-utils.scm
+++ b/guix/build/lisp-utils.scm
@@ -107,38 +107,33 @@ (define (lisp-invocation program)
              "--eval" "(quit)"))
     (_ (error "The LISP provided is not supported at this time."))))
 
-(define (compile-systems systems asd-files)
+(define (compile-systems systems directory)
   "Use a lisp implementation to compile the SYSTEMS using asdf.
 Load ASD-FILES first."
   (lisp-eval-program
    `((require :asdf)
-     ,@(map (lambda (asd-file)
-              `(asdf:load-asd (truename ,asd-file)))
-            asd-files)
+     (asdf:initialize-source-registry
+      (list :source-registry (list :tree (uiop:ensure-pathname ,directory
+                                                               :truenamize t
+                                                               :ensure-directory t))
+            :inherit-configuration))
      ,@(map (lambda (system)
               `(asdf:load-system ,system))
             systems))))
 
-(define (test-system system asd-files test-asd-file)
+(define (test-system test-systems directory)
   "Use a lisp implementation to test SYSTEM using asdf.  Load ASD-FILES first.
 Also load TEST-ASD-FILE if necessary."
   (lisp-eval-program
    `((require :asdf)
-     ,@(map (lambda (asd-file)
-              `(asdf:load-asd (truename ,asd-file)))
-            asd-files)
-     ,@(if test-asd-file
-           `((asdf:load-asd (truename ,test-asd-file)))
-           ;; Try some likely files.
-           (map (lambda (file)
-                  `(when (uiop:file-exists-p ,file)
-                     (asdf:load-asd (truename ,file))))
-                (list
-                 (string-append system "-tests.asd")
-                 (string-append system "-test.asd")
-                 "tests.asd"
-                 "test.asd")))
-     (asdf:test-system ,system))))
+     (asdf:initialize-source-registry
+      (list :source-registry (list :tree (uiop:ensure-pathname ,directory
+                                                               :truenamize t
+                                                               :ensure-directory t))
+            :inherit-configuration))
+     ,@(map (lambda (system)
+              `(asdf:test-system ,system))
+            test-systems))))
 
 (define (string->lisp-keyword . strings)
   "Return a lisp keyword for the concatenation of STRINGS."
-- 
2.32.0

>From 22de0cac8481df8b9645e08420f54bb2beabe1ed Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Fri, 1 Jul 2022 18:20:18 +0200
Subject: [PATCH 03/18] gnu: sbcl-cl-gamepad: Remove asdf:compile-system
 workaround.

* gnu/packages/lisp-xyz.scm (sbcl-cl-gamepad)[arguments]: Remove 'build phase
patch now that asdf-build-system/sbcl builds using asdf:load-system which
fixes the bug.
---
 gnu/packages/lisp-xyz.scm | 30 +-----------------------------
 1 file changed, 1 insertion(+), 29 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 3d6ce68fb8..3b13d1739e 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -17878,35 +17878,7 @@ (define-public sbcl-cl-gamepad
                (substitute* "evdev-cffi.lisp"
                  (("libevdev.so" all)
                   (string-append (assoc-ref inputs "libevdev")
-                                 "/lib/" all)))))
-           ;; Here we use a custom build phase to work around a compilation bug.
-           ;; Using 'asdf:compile-system' fails, but using 'asdf:load-system'
-           ;; succeeds (and also compiles the system).
-           ;; See https://github.com/Shirakumo/cl-gamepad/issues/8
-           (replace 'build
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (source-path (string-append out
-                                                  "/share/common-lisp/"
-                                                  (%lisp-type)))
-                      (translations `((,source-path
-                                       :**/ :*.*.*)
-                                      (,(string-append out
-                                                       "/lib/common-lisp/"
-                                                       (%lisp-type))
-                                       :**/ :*.*.*))))
-                 (setenv "ASDF_OUTPUT_TRANSLATIONS"
-                         (format #f "~S" `(:output-translations
-                                           ,translations
-                                           :inherit-configuration)))
-                 (setenv "HOME" (assoc-ref outputs "out"))
-                 (with-directory-excursion (string-append source-path
-                                                          "/cl-gamepad")
-                   (invoke (%lisp-type)
-                           "--eval" "(require :asdf)"
-                           "--eval" "(asdf:load-asd (truename \"cl-gamepad.asd\"))"
-                           "--eval" "(asdf:load-system :cl-gamepad)"
-                           "--eval" "(quit)"))))))))
+                                 "/lib/" all))))))))
       (inputs
        `(("cffi" ,sbcl-cffi)
          ("documentation-utils" ,sbcl-documentation-utils)
-- 
2.32.0

>From 17d63b502101196c069c1e7d60c8a27392516ce6 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Fri, 1 Jul 2022 20:41:37 +0200
Subject: [PATCH 04/18] gnu: Remove obsolete references to asd-files and
 test-asd-file.

* gnu/packages/lisp-check.scm: Do it.
* gnu/packages/lisp.scm: Do it.

In a previous commit we've update the build system to let ASDF locate the .asd
files for us, so package definition no longer need to provide this information.
---
 gnu/packages/lisp-check.scm |   6 +-
 gnu/packages/lisp-xyz.scm   | 202 ++++++++----------------------------
 2 files changed, 45 insertions(+), 163 deletions(-)

diff --git a/gnu/packages/lisp-check.scm b/gnu/packages/lisp-check.scm
index 6b13daf9c5..097ab7b6ee 100644
--- a/gnu/packages/lisp-check.scm
+++ b/gnu/packages/lisp-check.scm
@@ -116,8 +116,7 @@ (define-public sbcl-checkl
        ;; Error while trying to load definition for system checkl-test from
        ;; pathname [...]/checkl-test.asd: The function CHECKL:DEFINE-TEST-OP
        ;; is undefined.
-       '(#:asd-files '("checkl.asd")
-         #:tests? #f))
+       '(#:tests? #f))
       (native-inputs
        (list sbcl-fiveam))
       (inputs
@@ -869,8 +868,7 @@ (define-public sbcl-try
              sbcl-mgl-pax
              sbcl-trivial-gray-streams))
       (arguments
-       `(#:asd-files '("try.asdf.asd" "try.asd")
-         ;; FIXME: Get tests to work
+       `(;; FIXME: Get tests to work
          #:tests? #f))
       (home-page "https://github.com/melisgl/try")
       (synopsis "Common Lisp test framework")
diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 3b13d1739e..00fae19ab9 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -265,12 +265,6 @@ (define-public sbcl-asdf-finalizers
       (native-inputs
        `(("fare-utils" ,sbcl-fare-utils)
          ("hu.dwim.stefil" ,sbcl-hu.dwim.stefil)))
-      (arguments
-       `(#:asd-files '("asdf-finalizers.asd"
-                       "list-of.asd"
-                       "asdf-finalizers-test.asd")
-         #:asd-systems '("asdf-finalizers"
-                         "list-of")))
       (home-page "https://gitlab.common-lisp.net/asdf/asdf-finalizers")
       (synopsis "Enforced calling of finalizers for Lisp code")
       (description "This library allows you to implement and enforce proper
@@ -373,10 +367,8 @@ (define-public sbcl-cl-irc
          ("split-sequence" ,sbcl-split-sequence)
          ("usocket" ,sbcl-usocket)))
       (arguments
-       `(#:asd-systems '("cl-irc") ;; Some inexisting "c" system is
-                                   ;; found by guix otherwise.
-         #:asd-files '("cl-irc.asd")
-         #:test-asd-file "test/cl-irc-test.asd"))
+        ;; Some inexisting "c" system is found by guix otherwise.
+       `(#:asd-systems '("cl-irc")))
       (synopsis "IRC client library for Common Lisp")
       (description "@code{cl-irc} is a Common Lisp IRC client library that
 features (partial) DCC, CTCP and all relevant commands from the IRC
@@ -867,8 +859,7 @@ (define-public sbcl-cl-ppcre-unicode
     (inputs
      (list sbcl-cl-ppcre sbcl-cl-unicode))
     (arguments
-     `(#:tests? #f ; tests fail with "Component :CL-PPCRE-TEST not found"
-       #:phases
+     `(#:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'disable-ppcre
            ;; cl-ppcre and cl-ppcre-unicode are put in different packages
@@ -996,8 +987,7 @@ (define-public sbcl-spatial-trees
            "11rhc6h501dwcik2igkszz7b9n515cr99m5pjh4r2qfwgiri6ysa"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       '(#:tests? #f           ; spatial-trees.test requires spatial-trees.nns
-         #:test-asd-file "spatial-trees.test.asd"))
+       '(#:tests? #f)) ; spatial-trees.test requires spatial-trees.nns
       (native-inputs
        (list sbcl-fiveam))
       (home-page "https://github.com/rpav/spatial-trees")
@@ -1449,8 +1439,7 @@ (define-public sbcl-trivial-features
         (base32 "0jsqah1znzqilxnw5vannb083ayk0d7phkackqzwwqkyg5hpn6pq"))))
     (build-system asdf-build-system/sbcl)
     (arguments
-     '(#:asd-files '("trivial-features.asd")
-       ;; FIXME: Tests disabled because of a circular dependency between
+     '(;; FIXME: Tests disabled because of a circular dependency between
        ;; trivial-features and cffi.
        #:tests? #f))
     ;; (native-inputs
@@ -2337,9 +2326,7 @@ (define-public sbcl-mgl-pax
              sbcl-pythonic-string-reader
              sbcl-slime-swank))
       (arguments
-       `(#:asd-files '("mgl-pax.asdf.asd"
-                       "mgl-pax.asd")
-         #:asd-systems '("mgl-pax"
+       `(#:asd-systems '("mgl-pax"
                          "mgl-pax/navigate"
                          "mgl-pax/document"
                          "mgl-pax/transcribe")
@@ -2980,11 +2967,6 @@ (define-public sbcl-cffi
                            (string-append
                             (assoc-ref outputs "out")
                             "/include/grovel")))))
-       #:asd-files '("cffi.asd"
-                     "cffi-toolchain.asd"
-                     "cffi-grovel.asd"
-                     "cffi-libffi.asd"
-                     "cffi-uffi-compat.asd")
        #:asd-systems '("cffi"
                        "cffi-libffi"
                        "cffi-uffi-compat")))
@@ -3345,16 +3327,7 @@ (define-public sbcl-cl-cffi-gtk
          ("trivial-features" ,sbcl-trivial-features)
          ("trivial-garbage" ,sbcl-trivial-garbage)))
       (arguments
-       `(#:asd-files '("gtk/cl-cffi-gtk.asd"
-                       "glib/cl-cffi-gtk-glib.asd"
-                       "gobject/cl-cffi-gtk-gobject.asd"
-                       "gio/cl-cffi-gtk-gio.asd"
-                       "cairo/cl-cffi-gtk-cairo.asd"
-                       "pango/cl-cffi-gtk-pango.asd"
-                       "gdk-pixbuf/cl-cffi-gtk-gdk-pixbuf.asd"
-                       "gdk/cl-cffi-gtk-gdk.asd")
-         #:test-asd-file "test/cl-cffi-gtk-test.asd"
-         ;; TODO: Tests fail with memory fault.
+       `(;; TODO: Tests fail with memory fault.
          ;; See https://github.com/Ferada/cl-cffi-gtk/issues/24.
          #:tests? #f
          #:phases
@@ -4711,8 +4684,7 @@ (define-public sbcl-fast-io
       ;; Error while trying to load definition for system fast-io-test from
       ;; pathname [...]/fast-io-test.asd: The function CHECKL:DEFINE-TEST-OP
       ;; is undefined.
-      '(#:tests? #f
-        #:asd-files '("fast-io.asd")))
+      '(#:tests? #f))
      (native-inputs
       (list sbcl-fiveam sbcl-checkl))
      (inputs
@@ -4874,7 +4846,6 @@ (define-public sbcl-lack
                          "lack-util"
                          "lack-middleware-backtrace"
                          "lack-middleware-static")
-         #:test-asd-file "t-lack.asd"
          ;; XXX: Component :CLACK not found
          #:tests? #f))
       (home-page "https://github.com/fukamachi/lack")
@@ -5602,8 +5573,6 @@ (define-public sbcl-fare-utils
           (base32
            "01wsr1aap3jdzhn4hrqjbhsjx6qci9dbd3gh4gayv1p49rbg8aqr"))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       `(#:test-asd-file "test/fare-utils-test.asd"))
       (native-inputs
        (list sbcl-hu.dwim.stefil))
       (synopsis "Collection of utilities and data structures")
@@ -5814,12 +5783,7 @@ (define-public sbcl-iolib
        ("split-sequence" ,sbcl-split-sequence)
        ("swap-bytes" ,sbcl-swap-bytes)))
     (arguments
-     '(#:asd-files '("iolib.asdf.asd"
-                     "iolib.conf.asd"
-                     "iolib.common-lisp.asd"
-                     "iolib.base.asd"
-                     "iolib.asd")
-       #:asd-systems '("iolib"
+     '(#:asd-systems '("iolib"
                        "iolib/os")
        #:phases
        (modify-phases %standard-phases
@@ -6151,8 +6115,7 @@ (define-public sbcl-lisp-namespace
       (native-inputs
        (list sbcl-fiveam))
       (arguments
-       `(#:test-asd-file "lisp-namespace.test.asd"
-        ;; XXX: Component LISP-NAMESPACE-ASD::LISP-NAMESPACE.TEST not found
+       `(;; XXX: Component LISP-NAMESPACE-ASD::LISP-NAMESPACE.TEST not found
          #:tests? #f))
       (synopsis "LISP-N, or extensible namespaces in Common Lisp")
       (description "Common Lisp already has major 2 namespaces, function
@@ -6305,8 +6268,6 @@ (define-public sbcl-type-i
          ("trivia.trivial" ,sbcl-trivia.trivial)))
       (native-inputs
        (list sbcl-fiveam))
-      (arguments
-       `(#:test-asd-file "type-i.test.asd"))
       (synopsis "Type inference utility on unary predicates for Common Lisp")
       (description "This library tries to provide a way to detect what kind of
 type the given predicate is trying to check.  This is different from inferring
@@ -6348,8 +6309,7 @@ (define-public sbcl-optima
        (list sbcl-eos))
       (arguments
        ;; XXX: Circular dependencies: tests depend on optima.ppcre which depends on optima.
-       `(#:tests? #f
-         #:test-asd-file "optima.test.asd"))
+       `(#:tests? #f))
       (synopsis "Optimized pattern matching library for Common Lisp")
       (description "Optima is a fast pattern matching library which uses
 optimizing techniques widely used in the functional programming world.")
@@ -6487,7 +6447,6 @@ (define-public sbcl-trivia
                        "trivia.quasiquote"
                        "trivia.cffi"
                        "trivia.fset")
-       #:test-asd-file "trivia.test.asd"
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'fix-build
@@ -6562,8 +6521,7 @@ (define-public sbcl-cl-str
     (native-inputs
      (list sbcl-prove))
     (arguments
-     `(#:asd-systems '("str")
-       #:test-asd-file "str.test.asd"))
+     `(#:asd-systems '("str")))
     (synopsis "Modern, consistent and terse Common Lisp string manipulation library")
     (description "A modern and consistent Common Lisp string manipulation
 library that focuses on modernity, simplicity and discoverability:
@@ -6959,8 +6917,7 @@ (define-public sbcl-cl-containers
       (inputs
        `(("metatilities-base" ,sbcl-metatilities-base)))
       (arguments
-       '(#:asd-files '("cl-containers.asd")
-         #:phases
+       '(#:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'relax-version-checks
              (lambda _
@@ -7012,9 +6969,6 @@ (define-public sbcl-cambl
          ("cl-containers" ,sbcl-cl-containers)
          ("local-time" ,sbcl-local-time)
          ("periods" ,sbcl-periods)))
-      (arguments
-       '(#:asd-files '("fprog.asd"
-                       "cambl.asd")))
       (synopsis "Commoditized amounts and balances for Common Lisp")
       (description
        "CAMBL is a Common Lisp library providing a convenient facility for
@@ -7356,9 +7310,6 @@ (define-public sbcl-cl-slug
          (sha256
           (base32 "1asdq6xllmsvfw5fky9wblqcx9isac9jrrlkfl7vyxcq1wxrnflx"))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       `(#:asd-files '("cl-slug-test.asd" "cl-slug.asd")
-         #:asd-systems '("cl-slug-test" "cl-slug")))
       (native-inputs
        (list sbcl-prove))
       (inputs
@@ -7716,8 +7667,6 @@ (define-public sbcl-cl-heap
     (build-system asdf-build-system/sbcl)
     (native-inputs
      (list sbcl-xlunit))
-    (arguments
-     `(#:test-asd-file "cl-heap-tests.asd"))
     (synopsis "Heap and priority queue data structures for Common Lisp")
     (description
      "CL-HEAP provides various implementations of heap data structures (a
@@ -8688,8 +8637,6 @@ (define-public sbcl-vas-string-metrics
          (sha256
           (base32 "11fcnd03ybzz37rkg3z0wsb727yqgcd9gn70sccfb34l89ia279k"))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       `(#:test-asd-file "test.vas-string-metrics.asd"))
       (home-page "https://github.com/vsedach/vas-string-metrics")
       (synopsis "String distance algorithms for Common Lisp")
       (description
@@ -9522,8 +9469,7 @@ (define-public sbcl-hdf5-cffi
       (native-inputs
        (list sbcl-fiveam))
       (arguments
-       `(#:test-asd-file "hdf5-cffi.test.asd"
-         ;; Tests depend on hdf5-cffi.examples.asd in addition to hdf5-cffi.asd,
+       `(;; Tests depend on hdf5-cffi.examples.asd in addition to hdf5-cffi.asd,
          ;; I don't know if there is a way to tell asdf-build-system to load
          ;; an additional system first, so tests are disabled.
          #:tests? #f
@@ -9709,9 +9655,7 @@ (define-public sbcl-type-r
        `(("trivia" ,sbcl-trivia)
          ("alexandria" ,sbcl-alexandria)))
       (native-inputs
-       (list sbcl-fiveam))
-      (arguments
-       `(#:test-asd-file "type-r.test.asd")))))
+       (list sbcl-fiveam)))))
 
 (define-public cl-type-r
   (sbcl-package->cl-source-package sbcl-type-r))
@@ -9751,8 +9695,7 @@ (define-public sbcl-trivialib-type-unify
       (native-inputs
        (list sbcl-fiveam))
       (arguments
-       `(#:asd-systems '("trivialib.type-unify")
-         #:test-asd-file "trivialib.type-unify.test.asd")))))
+       `(#:asd-systems '("trivialib.type-unify"))))))
 
 (define-public cl-trivialib-type-unify
   (sbcl-package->cl-source-package sbcl-trivialib-type-unify))
@@ -9834,10 +9777,7 @@ (define-public sbcl-specialized-function
          ("trivial-cltl2" ,sbcl-trivial-cltl2)
          ("type-r" ,sbcl-type-r)))
       (native-inputs
-       (list sbcl-fiveam))
-      (arguments
-       `(#:asd-files '("specialized-function.asd")
-         #:test-asd-file "specialized-function.test.asd")))))
+       (list sbcl-fiveam)))))
 
 (define-public cl-specialized-function
   (sbcl-package->cl-source-package sbcl-specialized-function))
@@ -9874,10 +9814,7 @@ (define-public sbcl-constantfold
          ("iterate" ,sbcl-iterate)
          ("lisp-namespace" ,sbcl-lisp-namespace)))
       (native-inputs
-       (list sbcl-fiveam))
-      (arguments
-       `(#:asd-files '("constantfold.asd")
-         #:test-asd-file "constantfold.test.asd")))))
+       (list sbcl-fiveam)))))
 
 (define-public cl-constantfold
   (sbcl-package->cl-source-package sbcl-constantfold))
@@ -9915,10 +9852,7 @@ (define-public sbcl-gtype
          ("iterate" ,sbcl-iterate)
          ("type-r" ,sbcl-type-r)))
       (native-inputs
-       (list sbcl-fiveam))
-      (arguments
-       `(#:asd-files '("gtype.asd")
-         #:test-asd-file "gtype.test.asd")))))
+       (list sbcl-fiveam)))))
 
 (define-public cl-gtype
   (sbcl-package->cl-source-package sbcl-gtype))
@@ -9949,9 +9883,7 @@ (define-public sbcl-numcl
           (base32 "15m4spbgayawnw5jjz04zfp0jnk9g6hgq5fmr648hzjzj50j1d78"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       `(#:test-asd-file "numcl.test.asd"
-         #:asd-files '("numcl.asd")
-         ;; Tests often fail because they require a dynamic-space-size much
+       `(;; Tests often fail because they require a dynamic-space-size much
          ;; bigger than the default one. Disable them for now.
          #:tests? #f))
       (native-inputs
@@ -10333,7 +10265,6 @@ (define-public sbcl-uffi
     (build-system asdf-build-system/sbcl)
     (arguments
      `(#:tests? #f ; TODO: Fix use of deprecated ASDF functions
-       #:asd-files '("uffi.asd")
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'fix-permissions
@@ -10391,13 +10322,8 @@ (define-public sbcl-clsql
        ("uffi" ,sbcl-uffi)
        ("zlib" ,zlib)))
     (arguments
-     `(#:asd-files '("clsql.asd"
-                     "clsql-uffi.asd"
-                     "clsql-sqlite3.asd"
-                     "clsql-postgresql.asd"
-                     "clsql-postgresql-socket3.asd"
-                     "clsql-mysql.asd")
-       #:asd-systems '("clsql"
+     `(#:asd-systems '("clsql"
+                       "clsql-uffi"
                        "clsql-sqlite3"
                        "clsql-postgresql"
                        "clsql-postgresql-socket3"
@@ -10500,8 +10426,8 @@ (define-public ecl-clsql
        (alist-delete "uffi" (package-inputs pkg)))
       (arguments
        (substitute-keyword-arguments (package-arguments pkg)
-         ((#:asd-files asd-files '())
-          `(cons "clsql-cffi.asd" ,asd-files)))))))
+         ((#:asd-systems asd-systems '())
+          `(cons "clsql-cffi" ,asd-systems)))))))
 
 (define-public sbcl-sycamore
   (let ((commit "fd2820fec165ad514493426dea209728f64e6d18"))
@@ -10692,10 +10618,6 @@ (define-public sbcl-modularize
          (sha256
           (base32 "1zys29rfkb649rkgl3snxhajk8d5yf7ryxkrwy020kwdh7zdsg7d"))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       `(#:test-asd-file "modularize-test-module.asd"
-         #:asd-files '("modularize.asd" "modularize-test-module.asd")
-         #:asd-systems '("modularize" "modularize-test-module")))
       (inputs
        `(("documentation-utils" ,sbcl-documentation-utils)
          ("trivial-package-local-nicknames" ,sbcl-trivial-package-local-nicknames)))
@@ -10901,7 +10823,9 @@ (define-public sbcl-quantile-estimator
          "0rlswkf0siaabsvvch3dgxmg45fw5w8pd9b7ri2w7a298aya52z9"))))
     (build-system asdf-build-system/sbcl)
     (arguments
-     '(#:asd-files '("quantile-estimator.asd")))
+     '(#:asd-test-systems '("quantile-estimator.test")
+       ;; TODO: Tests need https://github.com/sharplispers/mw-equiv.
+       #:tests? #f))
     (inputs
      `(("alexandria" ,sbcl-alexandria)))
     (home-page "https://github.com/deadtrickster/quantile-estimator.cl")
@@ -10948,13 +10872,7 @@ (define-public sbcl-prometheus
        ("split-sequence" ,sbcl-split-sequence)
        ("trivial-utf-8" ,sbcl-trivial-utf-8)))
     (arguments
-     '(#:asd-files '("prometheus.asd"
-                     "prometheus.collectors.sbcl.asd"
-                     "prometheus.collectors.process.asd"
-                     "prometheus.formats.text.asd"
-                     "prometheus.exposers.hunchentoot.asd"
-                     "prometheus.pushgateway.asd")
-       #:asd-systems '("prometheus"
+     '(#:asd-systems '("prometheus"
                        "prometheus.collectors.sbcl"
                        "prometheus.collectors.process"
                        "prometheus.formats.text"
@@ -11334,8 +11252,7 @@ (define-public sbcl-cl-online-learning
        `(("cl-libsvm-format" ,sbcl-cl-libsvm-format)
          ("cl-store" ,sbcl-cl-store)))
       (arguments
-       `(#:test-asd-file "cl-online-learning-test.asd"
-         #:asd-systems '("cl-online-learning-test"
+       `(#:asd-systems '("cl-online-learning-test"
                          "cl-online-learning")))
       (home-page "https://github.com/masatoi/cl-online-learning")
       (synopsis "Online Machine Learning for Common Lisp")
@@ -11373,8 +11290,7 @@ (define-public sbcl-cl-mpg123
              #t))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       `(#:asd-files '("cl-mpg123.asd" "cl-mpg123-example.asd")
-         #:asd-systems '("cl-mpg123" "cl-mpg123-example")
+       `(#:asd-systems '("cl-mpg123" "cl-mpg123-example")
          #:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'fix-paths
@@ -11973,8 +11889,6 @@ (define-public sbcl-opticl
              sbcl-retrospectiff
              sbcl-skippy
              sbcl-zpng))
-      (arguments
-       '(#:asd-files '("opticl.asd")))
       (home-page "https://github.com/slyrus/opticl")
       (synopsis "Image processing library for Common Lisp")
       (description
@@ -12351,8 +12265,7 @@ (define-public sbcl-hu.dwim.defclass-star
              ;; ("hu.dwim.stefil" ,cl-hu.dwim.stefil)
              sbcl-hu.dwim.asdf))
       (arguments
-       `(#:test-asd-file "hu.dwim.defclass-star.test.asd"
-         ;; Tests require a circular dependency: hu.dwim.stefil -> hu.dwim.def
+       `(;; Tests require a circular dependency: hu.dwim.stefil -> hu.dwim.def
          ;; -> hu.dwim.util -> hu.dwim.defclass-star.
          #:tests? #f))
       (home-page "https://github.com/hu-dwim/hu.dwim.defclass-star")
@@ -12694,8 +12607,7 @@ (define-public sbcl-cl-project
          ("prove" ,sbcl-prove)))
       (arguments
        ;; Tests depend on caveman, which in turns depends on cl-project.
-       '(#:tests? #f
-         #:asd-files '("cl-project.asd")))
+       '(#:tests? #f))
       (synopsis "Generate a skeleton for modern Common Lisp projects")
       (description "This library provides a modern project skeleton generator.
 In contract with other generators, CL-Project generates one package per file
@@ -12742,12 +12654,7 @@ (define-public sbcl-caveman
          ("trivial-types" ,sbcl-trivial-types)
          ("prove" ,sbcl-prove)))
       (arguments
-       `(#:asd-files '("caveman2.asd"
-                       "caveman2-db.asd"
-                       "caveman2-test.asd"
-                       "caveman-middleware-dbimanager.asd")
-         #:test-asd-file "caveman2-test.asd"
-         #:asd-systems '("caveman2"
+       `(#:asd-systems '("caveman2"
                          "caveman2-db"
                          "caveman2-test"
                          "caveman-middleware-dbimanager")
@@ -13001,8 +12908,7 @@ (define-public sbcl-custom-hash-table
           (base32 "1k4mvrpbqqds2fwjxp1bxmrfmr8ch4dkwhnkbw559knbqshvrlj5"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       '(#:asd-files '("cl-custom-hash-table.asd")
-         #:asd-systems '("cl-custom-hash-table")))
+       '(#:asd-systems '("cl-custom-hash-table")))
       (home-page "https://github.com/metawilm/cl-custom-hash-table")
       (synopsis "Custom hash tables for Common Lisp")
       (description "This library allows creation of hash tables with arbitrary
@@ -13265,10 +13171,6 @@ (define-public sbcl-deploy
          (sha256
           (base32 "07pfkibaridihg8lbq2czwa4iqifqk24n6rx7bfnv7i49p1ppja1"))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       `(#:test-asd-file "deploy-test.asd"
-         #:asd-files '("deploy.asd"
-                       "deploy-test.asd")))
       (native-inputs
        `(("cl-mpg123" ,sbcl-cl-mpg123)
          ("cl-out123" ,sbcl-cl-out123)))
@@ -14972,8 +14874,7 @@ (define-public sbcl-cl-difflib
       ;; Due to the age of this library tests use some deprecated
       ;; functionality and keep failing.
       (arguments
-       '(#:tests? #f
-         #:asd-files '("cl-difflib.asd")))
+       '(#:tests? #f))
       (home-page "https://github.com/wiseman/cl-difflib")
       (synopsis "Compute differences between pairs of sequences")
       (description
@@ -15589,8 +15490,6 @@ (define-public sbcl-quickproject
     (inputs
      `(("cl-fad" ,sbcl-cl-fad)
        ("html-template" ,sbcl-html-template)))
-    (arguments
-     '(#:asd-files '("quickproject.asd")))
     (home-page "https://xach.com/lisp/quickproject/")
     (synopsis "Create Common Lisp project skeletons")
     (description
@@ -15695,7 +15594,7 @@ (define-public sbcl-cl-conspack
      ;; failing test where it's in use.
      (arguments
       '(#:tests? #f
-        #:asd-files '("cl-conspack.asd")))
+        #:asd-test-systems '("cl-conspack-test")))
      (native-inputs
       (list sbcl-checkl))
      (inputs
@@ -16845,8 +16744,7 @@ (define-public sbcl-parser-combinators
       (arguments
        ;; FIXME: (Sharlatan-20210523T184237+0100): Tests require `femlisp', which
        ;; is quite chunky not packaged system yet, enable them when it's packed.
-       `(#:tests? #f
-         #:test-asd-file "parser-combinators-tests.asd"))
+       `(#:tests? #f))
       ;; (native-inputs
       ;;  `(("hu.dwim.stefil" ,sbcl-hu.dwim.stefil)
       ;;    ("infix" ,sbcl-femlisp)))
@@ -17151,11 +17049,9 @@ (define-public sbcl-flow
          (sha256
           (base32 "0ysw1kwiqlf8kzllhnz8v3q40dmvwf83fzq8bfkbmwy5hfjh3pxp"))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       ;; FIXME: (Sharlatan-20210527T203118+0100): FLOW-VISUALIZER requires
-       ;; COMMONQT which is not packed yet and required tweaks with QT. Remove
-       ;; this when it's ready.
-       `(#:asd-files '("flow.asd")))
+      ;; FIXME: (Sharlatan-20210527T203118+0100): FLOW-VISUALIZER requires
+      ;; COMMONQT which is not packed yet and required tweaks with QT. Remove
+      ;; this when it's ready.
       (inputs
        `(("closer-mop" ,sbcl-closer-mop)
          ("documentation-utils" ,sbcl-documentation-utils)))
@@ -17284,8 +17180,6 @@ (define-public sbcl-cepl
        (sha256
         (base32 "0izbw2advqm3wailj3dpq6zqfrfirwn14pw5qmqh8i71r51xwmm2"))))
      (build-system asdf-build-system/sbcl)
-     (arguments
-      `(#:asd-files '("cepl.asd" "cepl.build.asd")))
      (inputs
       `(("alexandria" ,sbcl-alexandria)
         ("bordeaux-threads" ,sbcl-bordeaux-threads)
@@ -17683,8 +17577,7 @@ (define-public sbcl-cl-posix-mqueue
           (base32 "04519rg8vc782z097dzlb8nx0skab2fy2zd0m60r6mz2nw8xdvh6"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       `(#:test-asd-file "cl-posix-mqueue-tests.asd"
-         #:phases
+       `(#:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'patch-librt-path
              (lambda* (#:key inputs #:allow-other-keys)
@@ -19930,10 +19823,6 @@ (define-public sbcl-bit-smasher
       (inputs
        `(("cl-base64" ,sbcl-cl-base64)
          ("cl-base58" ,sbcl-cl-base58)))
-      ;; Load order matters for tests, both for file reading and evaluation.
-      (arguments
-       `(#:asd-systems '("bit-smasher-test" "bit-smasher")
-         #:asd-files '("bit-smasher.asd" "bit-smasher-test.asd")))
       (home-page "https://github.com/thephoeron/bit-smasher/")
       (synopsis "Handle bit vectors, bit vector arithmetic, and type conversions")
       (description
@@ -19987,8 +19876,7 @@ (define-public sbcl-overlord
       (native-inputs
        (list sbcl-fiveam))
       (arguments
-       `(#:asd-files '("overlord.asd")
-         #:phases
+       `(#:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'include-overlord/net
              (lambda _
@@ -20746,9 +20634,6 @@ (define-public sbcl-asd-generator
            (base32 "0yiybl7b9x1f85v0drj0yw9821y3yfhya4n6gycnv5vvx6jp9by4"))
           (file-name (git-file-name "cl-asd-generator" commit))))
       (build-system asdf-build-system/sbcl)
-      (arguments
-       `(#:asd-systems '("asd-generator")
-         #:asd-files '("asd-generator.asd")))
       (inputs
        (list sbcl-cl-fad
              sbcl-iterate
@@ -21220,8 +21105,7 @@ (define-public sbcl-jzon
           (base32 "1048f6prz2lp859nxwcgghn6n38pc2pb580azzxpdhfcdi0034mj"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       '(#:asd-files '("src/com.inuoe.jzon.asd" "test/com.inuoe.jzon-tests.asd")
-         #:asd-systems '("com.inuoe.jzon" "com.inuoe.jzon-tests")))
+       '(#:asd-systems '("com.inuoe.jzon" "com.inuoe.jzon-tests")))
       (native-inputs
         (list sbcl-alexandria
               sbcl-fiveam
-- 
2.32.0

>From 3f69d656a84a42f6ed593936057d96874ee81e58 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 19:02:28 +0200
Subject: [PATCH 05/18] gnu: quri: Remove obsolete test workaround.

* gnu/packages/lisp-xyz.scm (quri)[arguments]: Remove.
---
 gnu/packages/lisp-xyz.scm | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 00fae19ab9..255716f2e3 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -4441,12 +4441,6 @@ (define-public sbcl-quri
        (sha256
         (base32 "0zpwjhs2zz9832wsjs00kbkjjl4bcs96krlnq9y75gi4f34fxj1x"))))
     (build-system asdf-build-system/sbcl)
-    (arguments
-     ;; Test system must be loaded before, otherwise tests fail with:
-     ;; Component QURI-ASD::QURI-TEST not found, required by #<SYSTEM
-     ;; "quri">.
-     '(#:asd-systems '("quri-test"
-                       "quri")))
     (native-inputs (list sbcl-prove))
     (inputs (list sbcl-babel sbcl-split-sequence sbcl-cl-utilities
                   sbcl-alexandria))
-- 
2.32.0

>From 399cae8e71a33b99eacdfe28a1ad0f714e9ff358 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 19:03:48 +0200
Subject: [PATCH 06/18] gnu: sbcl-cl-reexport: Remove obsolete test workaround.

* gnu/packages/lisp-xyz.scm (sbcl-cl-reexport)[arguments]: Remove.
---
 gnu/packages/lisp-xyz.scm | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 255716f2e3..fc93aa47f8 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -5960,11 +5960,6 @@ (define-public sbcl-cl-reexport
        (list sbcl-alexandria))
       (native-inputs
        (list sbcl-prove))
-      (arguments
-       ;; FIXME: Test fails with the following, why?
-       ;; Component "cl-reexport-test" not found, required by
-       ;; #<SYSTEM "cl-reexport-test">
-       `(#:tests? #f))
       (synopsis "Reexport external symbols in other Common Lisp packages")
       (description
        "Cl-reexport makes a package reexport symbols which are external
-- 
2.32.0

>From 4e048b16ede8dd65dec67ae562806b8c17270736 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 19:11:31 +0200
Subject: [PATCH 07/18] gnu: Add legion.

* gnu/packages/lisp-xyz.scm (cl-legion, ecl-legion, sbcl-legion): New variables.
---
 gnu/packages/lisp-xyz.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index fc93aa47f8..a483c10828 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -4697,6 +4697,41 @@ (define-public cl-fast-io
 (define-public ecl-fast-io
   (sbcl-package->ecl-package sbcl-fast-io))
 
+(define-public sbcl-legion
+  (let ((commit "599cca19f0e34246814621f7fe90322221c2e263")
+        (revision "1"))
+    (package
+     (name "sbcl-legion")
+     (version (git-version "0.1.1" revision commit))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/fukamachi/legion/")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0583pw0mf8bd4dj42w2xrlzcwfkl8q28n1bh8dpxxfg93crx4si6"))))
+     (build-system asdf-build-system/sbcl)
+     (native-inputs
+      (list sbcl-prove sbcl-local-time))
+     (inputs
+      (list
+       sbcl-bordeaux-threads
+       sbcl-cl-speedy-queue
+       sbcl-vom))
+     (home-page "https://github.com/fukamachi/legion")
+     (synopsis "Simple multithreading worker mechanism for Common Lisp")
+     (description
+      "This library provides a simple multithreading worker mechanism.")
+     (license license:bsd-3))))
+
+(define-public cl-legion
+  (sbcl-package->cl-source-package sbcl-legion))
+
+(define-public ecl-legion
+  (sbcl-package->ecl-package sbcl-legion))
+
 (define-public sbcl-jonathan
   (let ((commit "1f448b4f7ac8265e56e1c02b32ce383e65316300")
         (revision "1"))
-- 
2.32.0

>From c616fe249857d20ed9e7af2995837e072f9aa5cc Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 19:13:40 +0200
Subject: [PATCH 08/18] gnu: sbcl-jonathan: Fix tests.

* gnu/packages/lisp-xyz.scm (sbcl-jonathan)[native-inputs]: Add missing
sbcl-legion input.
[arguments]: Enable tests.
---
 gnu/packages/lisp-xyz.scm | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index a483c10828..5042b8814f 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -4748,12 +4748,8 @@ (define-public sbcl-jonathan
        (sha256
         (base32 "14x4iwz3mbag5jzzzr4sb6ai0m9r4q4kyypbq32jmsk2dx1hi807"))))
      (build-system asdf-build-system/sbcl)
-     (arguments
-      ;; Tests fail with: Component JONATHAN-ASD::JONATHAN-TEST not found,
-      ;; required by #<SYSTEM "jonathan">. Why?
-      `(#:tests? #f))
      (native-inputs
-      (list sbcl-prove))
+      (list sbcl-prove sbcl-legion))
      (inputs
       (list sbcl-cl-syntax sbcl-fast-io sbcl-proc-parse sbcl-cl-ppcre))
      (home-page "https://rudolph-miller.github.io/jonathan/overview.html")
-- 
2.32.0

>From e7c9ed5e5849750dce88a50eea4ad35f8433ab42 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 19:21:53 +0200
Subject: [PATCH 09/18] gnu: sbcl-cl-irc: Fix tests.

* gnu/packages/lisp-xyz.scm (sbcl-cl-irc)[arguments]: Specify test system.
---
 gnu/packages/lisp-xyz.scm | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 5042b8814f..ebf61c2c5c 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -359,7 +359,6 @@ (define-public sbcl-cl-irc
           (base32 "1b3nqbb4pj377lxl47rfgrs82pidadnrc65l48bk553c2f59b52w"))))
       (build-system asdf-build-system/sbcl)
       (native-inputs
-       ;; Tests only.
        (list sbcl-rt))
       (inputs
        `(("cl+ssl" ,sbcl-cl+ssl)
@@ -367,8 +366,7 @@ (define-public sbcl-cl-irc
          ("split-sequence" ,sbcl-split-sequence)
          ("usocket" ,sbcl-usocket)))
       (arguments
-        ;; Some inexisting "c" system is found by guix otherwise.
-       `(#:asd-systems '("cl-irc")))
+       `(#:asd-test-systems '("cl-irc-test")))
       (synopsis "IRC client library for Common Lisp")
       (description "@code{cl-irc} is a Common Lisp IRC client library that
 features (partial) DCC, CTCP and all relevant commands from the IRC
-- 
2.32.0

>From 71c8687604bb37cf46f1bc43677c39ecaea3befb Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 19:58:10 +0200
Subject: [PATCH 10/18] gnu: sbcl-spatial-trees: Build spatial-trees.nss and
 fix tests.

* gnu/packages/lisp-xyz.scm (sbcl-spatial-trees)[arguments]: Do it.
[inputs] Add sbcl-alexandria, sbcl-optima, sbcl-iterate.
---
 gnu/packages/lisp-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index ebf61c2c5c..157564dcfe 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -985,7 +985,11 @@ (define-public sbcl-spatial-trees
            "11rhc6h501dwcik2igkszz7b9n515cr99m5pjh4r2qfwgiri6ysa"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       '(#:tests? #f)) ; spatial-trees.test requires spatial-trees.nns
+       ;; We cannot build "spatial-trees-viz" here because it depends on
+       ;; mcclim which depends on spatial-trees.  FIXME: Break the circle.
+       '(#:asd-systems '("spatial-trees" "spatial-trees.nns")))
+      (inputs
+       (list sbcl-alexandria sbcl-optima sbcl-iterate))
       (native-inputs
        (list sbcl-fiveam))
       (home-page "https://github.com/rpav/spatial-trees")
-- 
2.32.0

>From d0694b81a260561afae95b675e1033871c8abdd9 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 20:13:02 +0200
Subject: [PATCH 11/18] gnu: sbcl-lisp-namespace: Enable tests.

* gnu/packages/lisp-xyz.scm (sbcl-lisp-namespace)[arguments]: Enable tests.
---
 gnu/packages/lisp-xyz.scm | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 157564dcfe..9785a29ab7 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -6136,9 +6136,6 @@ (define-public sbcl-lisp-namespace
        `(("alexandria" ,sbcl-alexandria)))
       (native-inputs
        (list sbcl-fiveam))
-      (arguments
-       `(;; XXX: Component LISP-NAMESPACE-ASD::LISP-NAMESPACE.TEST not found
-         #:tests? #f))
       (synopsis "LISP-N, or extensible namespaces in Common Lisp")
       (description "Common Lisp already has major 2 namespaces, function
 namespace and value namespace (or variable namespace), but there are actually
-- 
2.32.0

>From 67874a3df882362bcb110c7e1bce578a09397f94 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 20:30:32 +0200
Subject: [PATCH 12/18] gnu: sbcl-cl-heap: Re-enable tests.

* gnu/packages/lisp-xyz.scm (sbcl-cl-heap)[arguments]: Specify the name
of the test system.
---
 gnu/packages/lisp-xyz.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 9785a29ab7..985422ab13 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -7686,6 +7686,8 @@ (define-public sbcl-cl-heap
     (build-system asdf-build-system/sbcl)
     (native-inputs
      (list sbcl-xlunit))
+    (arguments
+     '(#:asd-test-systems '("cl-heap-tests")))
     (synopsis "Heap and priority queue data structures for Common Lisp")
     (description
      "CL-HEAP provides various implementations of heap data structures (a
-- 
2.32.0

>From 2a6674306f1b5784664ac9bb6f40a22299c94135 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 20:46:24 +0200
Subject: [PATCH 13/18] gnu: sbcl-vas-string-metrics: Re-enable tests.

* gnu/packages/lisp-xyz.scm (sbcl-vas-string-metrics)[arguments]: Specify the name
of the test system and fix the .asd file to actually do something.
---
 gnu/packages/lisp-xyz.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 985422ab13..953e5d3158 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -8658,6 +8658,18 @@ (define-public sbcl-vas-string-metrics
          (sha256
           (base32 "11fcnd03ybzz37rkg3z0wsb727yqgcd9gn70sccfb34l89ia279k"))))
       (build-system asdf-build-system/sbcl)
+      (arguments
+       '(#:asd-test-systems '("test.vas-string-metrics")
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'fix-test-asd
+             (lambda _
+               (substitute* "test.vas-string-metrics.asd"
+                 ((":depends-on")
+                  (string-append
+                   ":perform (test-op (op c) (symbol-call :vas-string-metrics :run-tests))"
+                   "\n"
+                   "  :depends-on"))))))))
       (home-page "https://github.com/vsedach/vas-string-metrics")
       (synopsis "String distance algorithms for Common Lisp")
       (description
-- 
2.32.0

>From 3da4d4ce53ff539d194c0da464e75f507c3d730d Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 20:50:06 +0200
Subject: [PATCH 14/18] gnu: sbcl-hdf5-cffi: Enable tests.

* gnu/packages/lisp-xyz.scm (sbcl-hdf5-cffi)[arguments]: Do it.
---
 gnu/packages/lisp-xyz.scm | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 953e5d3158..f4b9cae360 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -9502,11 +9502,7 @@ (define-public sbcl-hdf5-cffi
       (native-inputs
        (list sbcl-fiveam))
       (arguments
-       `(;; Tests depend on hdf5-cffi.examples.asd in addition to hdf5-cffi.asd,
-         ;; I don't know if there is a way to tell asdf-build-system to load
-         ;; an additional system first, so tests are disabled.
-         #:tests? #f
-         #:phases
+       `(#:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'fix-paths
              (lambda* (#:key inputs #:allow-other-keys)
-- 
2.32.0

>From 28e8197a9e65dd9a2dac7d6ce25d3fd14ece8b11 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 21:09:52 +0200
Subject: [PATCH 15/18] gnu: Add mw-equiv.

* gnu/packages/lisp-xyz.scm (cl-mw-equiv, ecl-mw-equiv, sbcl-mw-equiv): New variables.
---
 gnu/packages/lisp-xyz.scm | 52 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index f4b9cae360..6a2156f7cd 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -10836,6 +10836,58 @@ (define-public cl-clx-xembed
 (define-public ecl-clx-xembed
   (sbcl-package->ecl-package sbcl-clx-xembed))
 
+(define-public sbcl-mw-equiv
+  (let ((commit "3ae871458685b1ef7cd6a996ee22c8c5e738a03d")
+        (revision "1"))
+    (package
+      (name "sbcl-mw-equiv")
+      (version (git-version "0.1.2" revision commit))
+      (home-page "https://github.com/sharplispers/mw-equiv/")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/sharplispers/mw-equiv/")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1fl90wp0jp7l90mps53fq0kzb28f10qfr739527h03xwqccyylad"))))
+      (build-system asdf-build-system/sbcl)
+      (synopsis "Extensible object equivalence protocol for Common Lisp")
+      (description "Common Lisp comes with quite some functions to compare
+objects for equality, yet none is applicable in every situation and in general
+this is hard, as equality of objects depends on the semantics of operations on
+them.  As consequence, users find themselves regularly in a situation where
+they have to roll their own specialized equality test.
+
+This module provides one of many possible equivalence relations between
+standard Common Lisp objects.  However, it can be extended for new objects
+through a simple CLOS protocol.  The rules when two objects are considered
+equivalent distinguish between @emph{mutating} and @emph{frozen objects}.  A
+frozen object is promised not to be mutated in the future in a way that
+operations on it can notice the difference.
+
+We have chosen to compare mutating objects only for identity (pointer
+equality), to avoid various problems.  Equivalence for frozen objects on the
+other hand is established by recursing on the objects' constituent parts and
+checking their equivalence.  Hence, two objects are equivalent under the
+@code{OBJECT=} relation, if they are either identical, or if they are frozen
+and structurally equivalent, i.e. their constituents are point-wise
+equivalent.
+
+Since many objects are potentially mutable, but are not necessarily mutated
+from a certain point in their life time on, it is possible to promise to the
+equivalence relation that they remain frozen for the rest of their life time,
+thus enabling coarser equivalence than the often too fine-grained pointer
+equality.")
+      (license license:bsd-2))))
+
+(define-public cl-mw-equiv
+  (sbcl-package->cl-source-package sbcl-mw-equiv))
+
+(define-public ecl-mw-equiv
+  (sbcl-package->ecl-package sbcl-mw-equiv))
+
 (define-public sbcl-quantile-estimator
   (package
     (name "sbcl-quantile-estimator")
-- 
2.32.0

>From e0a00f33226849beb4c436ccc74352fbb6b02e75 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 21:10:05 +0200
Subject: [PATCH 16/18] gnu: sbcl-quantile-estimator: Enable tests.

* gnu/packages/lisp-xyz.scm (sbcl-quantile-estimator)[arguments]: Do it.
[native-inputs]: Add sbcl-mw-equiv, sbcl-prove, sbcl-log4cl.
---
 gnu/packages/lisp-xyz.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 6a2156f7cd..3f78cc2b9b 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -10904,11 +10904,11 @@ (define-public sbcl-quantile-estimator
          "0rlswkf0siaabsvvch3dgxmg45fw5w8pd9b7ri2w7a298aya52z9"))))
     (build-system asdf-build-system/sbcl)
     (arguments
-     '(#:asd-test-systems '("quantile-estimator.test")
-       ;; TODO: Tests need https://github.com/sharplispers/mw-equiv.
-       #:tests? #f))
+     '(#:asd-test-systems '("quantile-estimator.test")))
     (inputs
-     `(("alexandria" ,sbcl-alexandria)))
+     (list sbcl-alexandria))
+    (native-inputs
+     (list sbcl-mw-equiv sbcl-prove sbcl-log4cl))
     (home-page "https://github.com/deadtrickster/quantile-estimator.cl")
     (synopsis
      "Effective computation of biased quantiles over data streams")
-- 
2.32.0

>From 0cbf96a85f9f9595dcaf5b728ae4d237af24ea21 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 21:12:26 +0200
Subject: [PATCH 17/18] gnu: sbcl-cl-online-learning: Remove unnecessary
 arguments.

* gnu/packages/lisp-xyz.scm (sbcl-cl-online-learning)[arguments]: Do it.

The updated build system is now able to find the system on its own.
---
 gnu/packages/lisp-xyz.scm | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 3f78cc2b9b..20c7c10ee2 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -11332,9 +11332,6 @@ (define-public sbcl-cl-online-learning
       (inputs
        `(("cl-libsvm-format" ,sbcl-cl-libsvm-format)
          ("cl-store" ,sbcl-cl-store)))
-      (arguments
-       `(#:asd-systems '("cl-online-learning-test"
-                         "cl-online-learning")))
       (home-page "https://github.com/masatoi/cl-online-learning")
       (synopsis "Online Machine Learning for Common Lisp")
       (description
-- 
2.32.0

>From e7c633fcadd723f86166bee6b05b098935bef1be Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 4 Jul 2022 21:46:56 +0200
Subject: [PATCH 18/18] gnu: sbcl-jzon: Enable tests.

* gnu/packages/lisp-xyz.scm (sbcl-jzon)[arguments]: Move test system
to #:asd-test-systems.
Add phase to fix test .asd to actually run the tests.
---
 gnu/packages/lisp-xyz.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 20c7c10ee2..cf4f6ffde6 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -21183,7 +21183,19 @@ (define-public sbcl-jzon
           (base32 "1048f6prz2lp859nxwcgghn6n38pc2pb580azzxpdhfcdi0034mj"))))
       (build-system asdf-build-system/sbcl)
       (arguments
-       '(#:asd-systems '("com.inuoe.jzon" "com.inuoe.jzon-tests")))
+       '(#:asd-systems '("com.inuoe.jzon")
+         #:asd-test-systems '("com.inuoe.jzon-tests")
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'fix-test-asd
+             (lambda _
+               (substitute* "test/com.inuoe.jzon-tests.asd"
+                 ((":depends-on")
+                  (string-append
+                   ":perform (test-op (op c) (symbol-call :fiveam :run!"
+                   " (find-symbol \"JZON\" :com.inuoe.jzon-tests)))"
+                   "\n"
+                   "  :depends-on"))))))))
       (native-inputs
         (list sbcl-alexandria
               sbcl-fiveam
-- 
2.32.0