diff mbox series

[bug#70487,core-updates,4/4] gnu: lsp-plugins: Test with lv2lint and lv2_validate.

Message ID 7ad4b3dc6f1788dc11b325d8c201023ee33dcaaa.1713647481.git.poomklao@yahoo.com
State New
Headers show
Series Add more tests to lsp-plugins | expand

Commit Message

Parnikkapore April 20, 2024, 11:02 p.m. UTC
* gnu/packages/music.scm (lsp-plugins): Add more tests.
[arguments]: Add (guix build json) to the environment.
[phases]: Run lv2_validate and lv2lint.
[native-inputs]: Add lv2 (for lv2_validate) and lv2lint.

Change-Id: Ie73c5943298611dd0f8b42455151306d86a29a1e
---
 gnu/packages/music.scm | 79 ++++++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 4a3e615c15..a234cbe3c2 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -90,6 +90,7 @@  (define-module (gnu packages music)
   #:use-module (guix download)
   #:use-module (guix gexp)
   #:use-module (guix git-download)
+  #:use-module (guix modules)
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (gnu packages)
@@ -6213,31 +6214,57 @@  (define-public lsp-plugins
       #:make-flags
       #~(list (string-append "CC=" #$(cc-for-target)))
       #:phases
-      #~(modify-phases %standard-phases
-          (replace 'configure
-            (lambda _
-              (invoke "make" "config"
-                      "STRICT=1"
-                      "TEST=1"
-                      "FEATURES=clap doc jack ladspa lv2 vst2 xdg"
-                      (string-append "PREFIX=" #$output)
-                      (string-append "ETCDIR=" #$output "/etc"))))
-          (replace 'check
-            (lambda* (#:key tests? #:allow-other-keys)
-              (when tests?
-                (invoke ".build/host/lsp-plugin-fw/lsp-plugins-test" "utest"))))
-          (add-after 'install 'move-large-subdirs
-            (lambda _
-              (define (move-to-output output path)
-                (let ((source (string-append #$output path))
-                      (target (string-append output path)))
-                  (mkdir-p (dirname target))
-                  (rename-file source target)))
-              (move-to-output #$output:doc "/share/doc") ; 29MB
-              (move-to-output #$output:lv2 "/lib/lv2") ; 32MB
-              (move-to-output #$output:bin "/bin") ; Avoid cluttering xdg menu
-              (move-to-output #$output:bin "/share")
-              (move-to-output #$output:bin "/etc"))))))
+      (with-imported-modules (source-module-closure '((guix build json)))
+        #~(modify-phases %standard-phases
+            (replace 'configure
+              (lambda _
+                (invoke "make" "config"
+                        "STRICT=1"
+                        "TEST=1"
+                        "FEATURES=clap doc jack ladspa lv2 vst2 xdg"
+                        (string-append "PREFIX=" #$output)
+                        (string-append "ETCDIR=" #$output "/etc"))))
+            (replace 'check
+              (lambda* (#:key tests? #:allow-other-keys)
+                (when tests?
+                  (invoke ".build/host/lsp-plugin-fw/lsp-plugins-test" "utest"))))
+            (add-after 'install 'move-large-subdirs
+              (lambda _
+                (define (move-to-output output path)
+                  (let ((source (string-append #$output path))
+                        (target (string-append output path)))
+                    (mkdir-p (dirname target))
+                    (rename-file source target)))
+                (move-to-output #$output:doc "/share/doc") ; 29MB
+                (move-to-output #$output:lv2 "/lib/lv2") ; 32MB
+                (move-to-output #$output:bin "/bin") ; Avoid cluttering xdg menu
+                (move-to-output #$output:bin "/share")
+                (move-to-output #$output:bin "/etc")))
+            (add-after 'move-large-subdirs 'postinstall-check
+              (lambda* (#:key tests? #:allow-other-keys)
+                (when tests?
+                  (use-modules (guix build json))
+                  (let* ((plugins-json
+                          (call-with-input-file
+                           ".build/target/lsp-plugin-fw/plugins.json"
+                           read-json))
+                         (plugin-objects
+                          (assoc-ref plugins-json "plugins"))
+                         (plugin-urls
+                          (map (lambda (obj) (assoc-ref obj "lv2_uri"))
+                               plugin-objects))
+                         (plugin-urls (filter ->bool plugin-urls)))
+                    (setenv
+                      "LV2_PATH"
+                      (string-append #$output:lv2 "/lib/lv2:" #$lv2 "/lib/lv2"))
+                    (for-each
+                     (lambda (url)
+                       (invoke "lv2lint" "-Mpack" "-t" "* Symbols" url))
+                     plugin-urls))
+                  (system
+                    (string-append "lv2_validate "
+                                   #$output:lv2
+                                   "/usr/lib/lv2/lsp-*.lv2/*.ttl")))))))))
     (inputs
      (list cairo
            freetype
@@ -6246,7 +6273,7 @@  (define-public lsp-plugins
            libx11
            libxrandr
            mesa))
-    (native-inputs (list pkg-config php))
+    (native-inputs (list pkg-config php lv2 lv2lint))
     (outputs '("out" "doc" "lv2" "debug"))
     (synopsis "Audio plugin collection")
     (description "LSP (Linux Studio Plugins) is a collection of audio