From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ODDYNw6SQGP1LgAAbAwnHQ (envelope-from ) for ; Fri, 07 Oct 2022 22:54:38 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id yK6/Nw6SQGMoKQEAauVa8A (envelope-from ) for ; Fri, 07 Oct 2022 22:54:38 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A0312EF73 for ; Fri, 7 Oct 2022 22:54:38 +0200 (CEST) Received: from localhost ([::1]:46854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oguMf-00063s-SI for larch@yhetil.org; Fri, 07 Oct 2022 16:54:37 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665176078; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=TWP8pWUy6TlUor/aXGtz1XUdfD0vWzqHuG48lxids1M=; b=unJWORP9wK708aBObp5ECuswXL51aN2iPeGB4XxOUHnEAeDEWcW1JTDuTiS5pDiyLIwo12 g06RPalzO49l98ewSFfMm5qPtXCXnMj2ASsi5Uw6+EwQ3XAUH1XVb1Mok9vK7DkT4K4S2p kfm//5GTYtPGypJaAB69Sb2WBsRdnQvqveCekTxi9rnHTEYeYB3X5spImZGRxRJ89P2YcD yri+QC1TZpPSDIMId0ZfbCVG+kGHc7UIRN8uSEjS4U+HwTTEdCY4AzNvd6WFGzI7hbSIxj ZuM9QVdFnn5okHrVxzCBh201Mou9Nuk0l+wms/eENOgyjcBmHQCAENyJplwXvQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665176078; a=rsa-sha256; cv=none; b=HpWPOus1uknLwM8UG90iEFw8ye+XjULFV/ZvbjcqBynorqtikg84wBYNKDvx0ydU1/naGD avPb12VsSbeZSk98SFDRkfP1viR8n8EZ737if0VV9bLGGB74UHelu4OMfcr9qqG1GtahL8 qltnoIVAi6NdNPxrz3Z/Z3111BQFTxaQFkSIRRsHpgZbW/97RjasnCK0BabSO+PX2B55wC dTxTvYemeQiQoHUvJUxEXdS27ETcFpJkHxhL9yPiq/+DPztGszb0t39MtrEAQfG+Pn6ZXC +tV4g64MllYtlpkjTdZR+ysM5rukL2O2gcAKMRs0Fu9bDwoEUvzQAJv2Q8ZVfg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r22 header.b=XpW1CFO+; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.63 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r22 header.b=XpW1CFO+; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A0312EF73 X-Spam-Score: 6.63 X-Migadu-Scanner: scn0.migadu.com X-TUID: ocnrTD5VCiqW 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))) -- 2.37.3