mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-25 20:19:18 -05:00
guix build: Add '--without-tests'.
* 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 commit is contained in:
parent
d753aee0be
commit
f458cfbcc5
3 changed files with 64 additions and 3 deletions
|
@ -9271,6 +9271,28 @@ guix build --with-branch=guile-sqlite3=master cuirass
|
||||||
This is similar to @option{--with-branch}, except that it builds from
|
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
|
@var{commit} rather than the tip of a branch. @var{commit} must be a valid
|
||||||
Git commit SHA1 identifier or a tag.
|
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
|
@end table
|
||||||
|
|
||||||
@node Additional Build Options
|
@node Additional Build Options
|
||||||
|
|
|
@ -393,6 +393,25 @@ (define rewrite
|
||||||
(rewrite obj)
|
(rewrite obj)
|
||||||
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
|
(define %transformations
|
||||||
;; Transformations that can be applied to things to build. The car is the
|
;; 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
|
;; key used in the option alist, and the cdr is the transformation
|
||||||
|
@ -403,7 +422,8 @@ (define %transformations
|
||||||
(with-graft . ,transform-package-inputs/graft)
|
(with-graft . ,transform-package-inputs/graft)
|
||||||
(with-branch . ,transform-package-source-branch)
|
(with-branch . ,transform-package-source-branch)
|
||||||
(with-commit . ,transform-package-source-commit)
|
(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
|
(define %transformation-options
|
||||||
;; The command-line interface to the above transformations.
|
;; The command-line interface to the above transformations.
|
||||||
|
@ -423,7 +443,9 @@ (define %transformation-options
|
||||||
(option '("with-commit") #t #f
|
(option '("with-commit") #t #f
|
||||||
(parser 'with-commit))
|
(parser 'with-commit))
|
||||||
(option '("with-git-url") #t #f
|
(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)
|
(define (show-transformation-options-help)
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
|
@ -443,7 +465,10 @@ (define (show-transformation-options-help)
|
||||||
build PACKAGE from COMMIT"))
|
build PACKAGE from COMMIT"))
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
--with-git-url=PACKAGE=URL
|
--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)
|
(define (options->transformation opts)
|
||||||
|
|
|
@ -264,5 +264,19 @@ (define-module (test-scripts-build)
|
||||||
((("x" dep3))
|
((("x" dep3))
|
||||||
(map package-source (list dep1 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)
|
(test-end)
|
||||||
|
|
Loading…
Reference in a new issue