GNU bug report logs - #43581
[PATCH] guix build: Add '--without-tests'.

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Wed, 23 Sep 2020 20:44:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43581 in the body.
You can then email your comments to 43581 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#43581; Package guix-patches. (Wed, 23 Sep 2020 20:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 23 Sep 2020 20:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH] guix build: Add '--without-tests'.
Date: Wed, 23 Sep 2020 22:42:49 +0200
* guix/scripts/build.scm (transform-package-tests): New procedure.
(%transformations, %transformation-options)
show-transformation-options-help): Add it.
* tests/scripts-build.scm ("options->transformation, without-tests"):
New test.
* doc/guix.texi (Package Transformation Options): Document it.
---
 doc/guix.texi           | 22 ++++++++++++++++++++++
 guix/scripts/build.scm  | 31 ++++++++++++++++++++++++++++---
 tests/scripts-build.scm | 14 ++++++++++++++
 3 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 949551a163..67d0a70ae0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9270,6 +9270,28 @@ guix build --with-branch=guile-sqlite3=master cuirass
 This is similar to @option{--with-branch}, except that it builds from
 @var{commit} rather than the tip of a branch.  @var{commit} must be a valid
 Git commit SHA1 identifier or a tag.
+
+@cindex test suite, skipping
+@item --without-tests=@var{package}
+Build @var{package} without running its tests.  This can be useful in
+situations where you want to skip the lengthy test suite of a
+intermediate package, or if a package's test suite fails in a
+non-deterministic fashion.  It should be used with care because running
+the test suite is a good way to ensure a package is working as intended.
+
+Turning off tests leads to a different store item.  Consequently, when
+using this option, anything that depends on @var{package} must be
+rebuilt, as in this example:
+
+@example
+guix install --without-tests=python python-notebook
+@end example
+
+The command above installs @code{python-notebook} on top of
+@code{python} built without running its test suite.  To do so, it also
+rebuilds everything that depends on @code{python}, including
+@code{python-notebook} itself.
+
 @end table
 
 @node Additional Build Options
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 38e0516c95..f238e9b876 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -393,6 +393,25 @@ a checkout of the Git repository at the given URL."
         (rewrite obj)
         obj)))
 
+(define (transform-package-tests specs)
+  "Return a procedure that, when passed a package, sets #:tests? #f in its
+'arguments' field."
+  (define (package-without-tests p)
+    (package/inherit p
+      (arguments
+       (substitute-keyword-arguments (package-arguments p)
+         ((#:tests? _ #f) #f)))))
+
+  (define rewrite
+    (package-input-rewriting/spec (map (lambda (spec)
+                                         (cons spec package-without-tests))
+                                       specs)))
+
+  (lambda (store obj)
+    (if (package? obj)
+        (rewrite obj)
+        obj)))
+
 (define %transformations
   ;; Transformations that can be applied to things to build.  The car is the
   ;; key used in the option alist, and the cdr is the transformation
@@ -403,7 +422,8 @@ a checkout of the Git repository at the given URL."
     (with-graft  . ,transform-package-inputs/graft)
     (with-branch . ,transform-package-source-branch)
     (with-commit . ,transform-package-source-commit)
-    (with-git-url . ,transform-package-source-git-url)))
+    (with-git-url . ,transform-package-source-git-url)
+    (without-tests . ,transform-package-tests)))
 
 (define %transformation-options
   ;; The command-line interface to the above transformations.
@@ -423,7 +443,9 @@ a checkout of the Git repository at the given URL."
           (option '("with-commit") #t #f
                   (parser 'with-commit))
           (option '("with-git-url") #t #f
-                  (parser 'with-git-url)))))
+                  (parser 'with-git-url))
+          (option '("without-tests") #t #f
+                  (parser 'without-tests)))))
 
 (define (show-transformation-options-help)
   (display (G_ "
@@ -443,7 +465,10 @@ a checkout of the Git repository at the given URL."
                          build PACKAGE from COMMIT"))
   (display (G_ "
       --with-git-url=PACKAGE=URL
-                         build PACKAGE from the repository at URL")))
+                         build PACKAGE from the repository at URL"))
+  (display (G_ "
+      --without-tests=PACKAGE
+                         build PACKAGE without running its tests")))
 
 
 (define (options->transformation opts)
diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm
index 32876e956a..12114fc8f5 100644
--- a/tests/scripts-build.scm
+++ b/tests/scripts-build.scm
@@ -264,5 +264,19 @@
                        ((("x" dep3))
                         (map package-source (list dep1 dep3))))))))))))
 
+(test-assert "options->transformation, without-tests"
+  (let* ((dep (dummy-package "dep"))
+         (p   (dummy-package "foo"
+                (inputs `(("dep" ,dep)))))
+         (t   (options->transformation '((without-tests . "dep")
+                                         (without-tests . "tar")))))
+    (with-store store
+      (let ((new (t store p)))
+        (match (bag-direct-inputs (package->bag new))
+          ((("dep" dep) ("tar" tar) _ ...)
+           ;; TODO: Check whether TAR has #:tests? #f when transformations
+           ;; apply to implicit inputs.
+           (equal? (package-arguments dep)
+                   '(#:tests? #f))))))))
 
 (test-end)
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43581; Package guix-patches. (Wed, 23 Sep 2020 21:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 43581 <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 43581 <at> debbugs.gnu.org
Subject: Re: [bug#43581] [PATCH] guix build: Add '--without-tests'.
Date: Wed, 23 Sep 2020 23:05:53 +0200
Ludovic Courtès writes:

Hi!

--without-tests...beautiful!

> * guix/scripts/build.scm (transform-package-tests): New procedure.
> (%transformations, %transformation-options)

Nitpick, use comma                          ^

> show-transformation-options-help): Add it.

[..]

> +Turning off tests leads to a different store item.  Consequently, when
> +using this option, anything that depends on @var{package} must be
> +rebuilt, as in this example:

This makes sense, so I'm curious about it's usefulness in practice, but
there have been several times during porting sessions where I have
disabled tests by editing the package.

[..]

Otherwise, L*G*TM :-)

Testing...

--8<---------------cut here---------------start------------->8---
23:02:36 janneke <at> dundal:~/src/guix/master [env]
$ time ./pre-inst-env guix build automake --without-tests=automake --verbosity=1
The following derivation will be built:
   /gnu/store/0m9qp0rf74d6sray1ip6h050fzmrrya3-automake-1.16.2.drv
building /gnu/store/0m9qp0rf74d6sray1ip6h050fzmrrya3-automake-1.16.2.drv...
|offloading build of /gnu/store/0m9qp0rf74d6sray1ip6h050fzmrrya3-automake-1.16.2.drv to 'kluit.dezyne.org'
/gnu/store/7qsz3avcfk6b6am0zj9ahsmjy8x6drxr-automake-1.16.2

real	0m14.316s
user	0m1.203s
sys	0m0.072s
23:02:55 janneke <at> dundal:~/src/guix/master [env]
--8<---------------cut here---------------end--------------->8---

That's pretty amazing ;-)

Greetings,
Janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




Information forwarded to guix-patches <at> gnu.org:
bug#43581; Package guix-patches. (Wed, 23 Sep 2020 21:36:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <rekado <at> elephly.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: guix-patches <at> gnu.org, 43581 <at> debbugs.gnu.org
Subject: Re: [bug#43581] [PATCH] guix build: Add '--without-tests'.
Date: Wed, 23 Sep 2020 23:37:04 +0200
Ludovic Courtès <ludo <at> gnu.org> writes:

> * guix/scripts/build.scm (transform-package-tests): New procedure.
> (%transformations, %transformation-options)
> show-transformation-options-help): Add it.
> * tests/scripts-build.scm ("options->transformation, without-tests"):
> New test.
> * doc/guix.texi (Package Transformation Options): Document it.

This looks good to me.  It’s much more convenient for the casual user
than to clone the Guix repo and to edit the package definition there, or
to extend the package collection with GUIX_PACKAGE_PATH or even a
channel.

I suppose we’d have to fix all those packages that moved the check phase
without also checking for the “#:tests?” keyword.  There are quite a few
of those that thus wouldn’t be affected by “--without-tests”.

-- 
Ricardo




Information forwarded to guix-patches <at> gnu.org:
bug#43581; Package guix-patches. (Wed, 23 Sep 2020 21:36:02 GMT) Full text and rfc822 format available.

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sun, 27 Sep 2020 20:59:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Sun, 27 Sep 2020 20:59:02 GMT) Full text and rfc822 format available.

Message #19 received at 43581-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Jan Nieuwenhuizen <janneke <at> gnu.org>
Cc: 43581-done <at> debbugs.gnu.org
Subject: Re: [bug#43581] [PATCH] guix build: Add '--without-tests'.
Date: Sun, 27 Sep 2020 22:58:44 +0200
Hi,

Jan Nieuwenhuizen <janneke <at> gnu.org> skribis:

>> * guix/scripts/build.scm (transform-package-tests): New procedure.
>> (%transformations, %transformation-options)
>
> Nitpick, use comma                          ^
>
>> show-transformation-options-help): Add it.

Oops yes, and I forgot to fix it before pushing.  :-/

>> +Turning off tests leads to a different store item.  Consequently, when
>> +using this option, anything that depends on @var{package} must be
>> +rebuilt, as in this example:
>
> This makes sense, so I'm curious about it's usefulness in practice, but
> there have been several times during porting sessions where I have
> disabled tests by editing the package.

Yeah, that’s the typical use case.

> $ time ./pre-inst-env guix build automake --without-tests=automake --verbosity=1
> The following derivation will be built:
>    /gnu/store/0m9qp0rf74d6sray1ip6h050fzmrrya3-automake-1.16.2.drv
> building /gnu/store/0m9qp0rf74d6sray1ip6h050fzmrrya3-automake-1.16.2.drv...
> |offloading build of /gnu/store/0m9qp0rf74d6sray1ip6h050fzmrrya3-automake-1.16.2.drv to 'kluit.dezyne.org'
> /gnu/store/7qsz3avcfk6b6am0zj9ahsmjy8x6drxr-automake-1.16.2
>
> real	0m14.316s
> user	0m1.203s
> sys	0m0.072s

That’s also one of the packages I had in mind.  :-)

Ricardo Wurmus <rekado <at> elephly.net> skribis:

> This looks good to me.  It’s much more convenient for the casual user
> than to clone the Guix repo and to edit the package definition there, or
> to extend the package collection with GUIX_PACKAGE_PATH or even a
> channel.

Yup.

> I suppose we’d have to fix all those packages that moved the check phase
> without also checking for the “#:tests?” keyword.  There are quite a few
> of those that thus wouldn’t be affected by “--without-tests”.

Right, hopefully there aren’t too many of those.

Pushed as f458cfbcc54ed87b1a87dd9e150ea276f17eab74, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 26 Oct 2020 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 154 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.