From patchwork Fri Oct 7 20:53:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 43211 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 67CD527BBEA; Fri, 7 Oct 2022 21:54:41 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B2E0327BBE9 for ; Fri, 7 Oct 2022 21:54:40 +0100 (BST) Received: from localhost ([::1]:46854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oguMh-00063s-Ss for patchwork@mira.cbaines.net; Fri, 07 Oct 2022 16:54:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oguM7-0005Vb-QO for guix-patches@gnu.org; Fri, 07 Oct 2022 16:54:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oguM7-0002y9-HP for guix-patches@gnu.org; Fri, 07 Oct 2022 16:54:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oguM7-0003ww-E1 for guix-patches@gnu.org; Fri, 07 Oct 2022 16:54:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58365] [PATCH 2/6] build-system/guile: Run SRFI-64 tests. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Oct 2022 20:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58365 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58365@debbugs.gnu.org Cc: Maxime Devos Received: via spool by 58365-submit@debbugs.gnu.org id=B58365.166517604115144 (code B ref 58365); Fri, 07 Oct 2022 20:54:03 +0000 Received: (at 58365) by debbugs.gnu.org; 7 Oct 2022 20:54:01 +0000 Received: from localhost ([127.0.0.1]:37545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oguM4-0003w6-HF for submit@debbugs.gnu.org; Fri, 07 Oct 2022 16:54:01 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:40930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oguM0-0003v2-L2 for 58365@debbugs.gnu.org; Fri, 07 Oct 2022 16:53:58 -0400 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:5dba:d409:33f7:a16]) by laurent.telenet-ops.be with bizsmtp id V8tu2800920ykKC018tvFL; Fri, 07 Oct 2022 22:53:55 +0200 From: Maxime Devos Date: Fri, 7 Oct 2022 22:53:48 +0200 Message-Id: <20221007205352.1282-2-maximedevos@telenet.be> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007205352.1282-1-maximedevos@telenet.be> References: <20221007205352.1282-1-maximedevos@telenet.be> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1665176035; bh=TWP8pWUy6TlUor/aXGtz1XUdfD0vWzqHuG48lxids1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XpW1CFO+OAN3fKGnJAUVQMIEq8MmNMFx/1NMoadgCG1oLz3LNpeCVXw3/DpTm6UGZ ciG8CmgVIXtlpPjWIvRz1EHN5dk83QjQrKI5fp8/7sb0K818jDqh8dOlRf3WNV1/5n fceIX0CpElLpIeF77DHgbtZmn5w5Kn8qtZAmpRPacrzQa6kIcWycsgscWI5q4k8dT7 ve0wkBr3Jo/tQaygnq1Y0KZqkSXkEMcuR0zPj1pnYAb5+7E2QNaW/INXBEKXP/WDh4 L02Yl0Dr98rQqAsSgQCaXncjKw98asdc9A/0RXsIxDf/rH1HMKK44gJimFjZnV/B2i Y87BtPwli7gbQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches The build system needs a hint for the location of the test suite(s), but aside from that tests are now run automatically. I expect having multiple test suites to be the exception, so I used 'test-script' instead of 'test-scripts'. Fixes: * guix/build-system/guile.scm (guile-build): Pass on 'tests?', 'test-script' and 'test-arguments'. (guile-cross-build): Likewise. * guix/build/guile-build-system.scm (guile-check): New phase. (%standard-phases)[check]: Use it. * doc/guix.texi (Build Systems)[guile-build-system]: Document new behaviour. --- doc/guix.texi | 15 ++++++++--- guix/build-system/guile.scm | 13 +++++++++ guix/build/guile-build-system.scm | 44 +++++++++++++++++++++++++++++-- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 08dab8e5b1..858bcec96f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9022,13 +9022,22 @@ code and that are so lean that they don't even have a makefile, let alone a @file{configure} script. It compiles Scheme code using @command{guild compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and installs the @file{.scm} and @file{.go} files in the right place. It also -installs documentation. +installs documentation and runs SRFI-64 test suites. + +Test suites cannot be found automatically; the location of the test +suite can be set with the @code{#:test-script} argument (as a string). +If there are multiple test scripts, this argument can be set to a staged +list of locations. Sometimes some tests need to be skipped, if so, +@code{#:test-arguments} can be a staged list with extra arguments to +pass to the test driver (see @code{test-driver.scm --help} for details). This build system supports cross-compilation by using the @option{--target} option of @samp{guild compile}. -Packages built with @code{guile-build-system} must provide a Guile package in -their @code{native-inputs} field. +Packages built with @code{guile-build-system} must provide a Guile +package in their @code{native-inputs} field. Additionally, if +@code{#:test-script} is used, a test driver (usually +@code{guile-test-driver}) must be provided. @end defvr @defvr {Scheme Variable} julia-build-system diff --git a/guix/build-system/guile.scm b/guix/build-system/guile.scm index 36a88e181a..75d62fe403 100644 --- a/guix/build-system/guile.scm +++ b/guix/build-system/guile.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018-2019, 2021-2022 Ludovic Courtès +;;; Copyright © 2022 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -78,6 +79,9 @@ (define %compile-flags (define* (guile-build name inputs #:key source + (tests? #true) + (test-script #false) + (test-arguments ''()) (guile #f) (phases '%standard-phases) (outputs '("out")) @@ -98,6 +102,9 @@ (define builder (guile-build #:name #$name #:source #+source + #:tests? #$tests? + #:test-script #$test-script + #:test-arguments #$test-arguments #:source-directory #$source-directory #:scheme-file-regexp #$scheme-file-regexp #:not-compiled-file-regexp #$not-compiled-file-regexp @@ -122,6 +129,9 @@ (define* (guile-cross-build name build-inputs target-inputs host-inputs (guile #f) source + (tests? #false) + (test-script #false) + (test-arguments ''()) (outputs '("out")) (search-paths '()) (native-search-paths '()) @@ -149,6 +159,9 @@ (define %outputs #$(outputs->gexp outputs)) (guile-build #:source #+source + #:tests? #$tests? + #:test-script #$test-script + #:test-arguments #$test-arguments #:system #$system #:target #$target #:outputs %outputs diff --git a/guix/build/guile-build-system.scm b/guix/build/guile-build-system.scm index 32a431d347..838cb13089 100644 --- a/guix/build/guile-build-system.scm +++ b/guix/build/guile-build-system.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2019 Ludovic Courtès +;;; Copyright © 2022 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,8 +20,10 @@ (define-module (guix build guile-build-system) #:use-module ((guix build gnu-build-system) #:prefix gnu:) #:use-module (guix build utils) + #:use-module (rnrs exceptions) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (ice-9 match) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) @@ -29,7 +32,8 @@ (define-module (guix build guile-build-system) #:use-module (guix build utils) #:export (target-guile-effective-version %standard-phases - guile-build)) + guile-build + guile-check)) (define* (target-guile-effective-version #:optional guile) "Return the effective version of GUILE or whichever 'guile' is in $PATH. @@ -201,6 +205,42 @@ (define* (build #:key outputs inputs native-inputs source-files)) #t)) +(define* (guile-check #:key tests? test-script (test-arguments '()) + (source-directory ".") + native-inputs inputs + #:allow-other-keys) + (when tests? + ;; Let Guile find the source code of newly compiled modules, + ;; otherwise the modules won't be found even if Guile knows + ;; where the compiled code is. + (setenv "GUILE_LOAD_PATH" + (string-append source-directory + (match (getenv "GUILE_LOAD_PATH") + (#f "") + (path (string-append ":" path))))) + (for-each + (lambda (test-script) + (guard (c ((invoke-error? c) + (when (equal? (list (invoke-error-exit-status c) + (invoke-error-term-signal c) + (invoke-error-stop-signal c)) + '(127 #false #false)) + (display "hint: Make sure 'guile-test-driver' is in\ + 'native-inputs'.\n" + (current-error-port))) + (raise-continuable c))) + (apply invoke "test-driver.scm" + (string-append "--test-name=" test-script) test-arguments))) + (match test-script + ;; Tests can be separated over multiple files. + ((? list? test-scripts) test-scripts) + ((? string? test-script) (list test-script)) + (#false + (format (current-error-port) + "warning: location of test suite is unknown; not running\ + tests~%") + '()))))) + (define* (install-documentation #:key outputs (documentation-file-regexp %documentation-file-regexp) @@ -222,7 +262,7 @@ (define %standard-phases (replace 'build build) (add-after 'build 'install-documentation install-documentation) - (delete 'check) + (replace 'check guile-check) (delete 'strip) (delete 'validate-runpath) (delete 'install)))