tests: Use bootstrap and Nixpkgs inputs to be less costly.

* tests/builders.scm (%bootstrap-inputs, %bootstrap-guile): New
  variables.
  ("gnu-build"): Use them, by setting `#:implicit-inputs? #f' and `#:guile'.

* tests/packages.scm (%bootstrap-inputs, %bootstrap-guile): New
  variables.
  ("trivial"): Pass `#:guile %bootstrap-guile'.
  ("GNU Hello"): Use `package-with-explicit-inputs' to use
  %BOOTSTRAP-GUILE and %BOOTSTRAP-INPUTS.
master
Ludovic Courtès 2012-10-06 01:24:46 +02:00
parent 81c7948d9a
commit 14da91e2f0
2 changed files with 40 additions and 9 deletions

View File

@ -32,6 +32,18 @@
(define %store (define %store
(false-if-exception (open-connection))) (false-if-exception (open-connection)))
(define %bootstrap-inputs
;; Derivations taken from Nixpkgs, so that the initial tests don't
;; take forever.
(and (file-exists? (%nixpkgs-directory))
`(("make" ,(nixpkgs-derivation "gnumake"))
("diffutils" ,(nixpkgs-derivation "diffutils"))
,@(@@ (distro packages base) %bootstrap-inputs))))
(define %bootstrap-guile
(@@ (distro packages base) %bootstrap-guile))
(test-begin "builders") (test-begin "builders")
(test-assert "http-fetch" (test-assert "http-fetch"
@ -48,13 +60,17 @@
(and (build-system? gnu-build-system) (and (build-system? gnu-build-system)
(eq? gnu-build (build-system-builder gnu-build-system)))) (eq? gnu-build (build-system-builder gnu-build-system))))
(test-skip (if (file-exists? (%nixpkgs-directory)) 1 0))
(test-assert "gnu-build" (test-assert "gnu-build"
(let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz") (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
(hash (nix-base32-string->bytevector (hash (nix-base32-string->bytevector
"0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
(tarball (http-fetch %store url 'sha256 hash)) (tarball (http-fetch %store url 'sha256 hash))
(build (gnu-build %store "hello-2.8" tarball (build (gnu-build %store "hello-2.8" tarball
`(("gawk" ,(nixpkgs-derivation "gawk"))))) %bootstrap-inputs
#:implicit-inputs? #f
#:guile %bootstrap-guile))
(out (derivation-path->output-path build))) (out (derivation-path->output-path build)))
(and (build-derivations %store (list (pk 'hello-drv build))) (and (build-derivations %store (list (pk 'hello-drv build)))
(valid-path? %store out) (valid-path? %store out)

View File

@ -35,6 +35,18 @@
(define %store (define %store
(false-if-exception (open-connection))) (false-if-exception (open-connection)))
(define %bootstrap-inputs
;; Derivations taken from Nixpkgs, so that the initial tests don't
;; take forever.
(and (file-exists? (%nixpkgs-directory))
`(("make" ,(nixpkgs-derivation "gnumake"))
("diffutils" ,(nixpkgs-derivation "diffutils"))
,@(@@ (distro packages base) %bootstrap-inputs))))
(define %bootstrap-guile
(@@ (distro packages base) %bootstrap-guile))
(test-begin "packages") (test-begin "packages")
(define-syntax-rule (dummy-package name* extra-fields ...) (define-syntax-rule (dummy-package name* extra-fields ...)
@ -70,7 +82,8 @@
(build-system trivial-build-system) (build-system trivial-build-system)
(source #f) (source #f)
(arguments (arguments
'(#:builder `(#:guile ,%bootstrap-guile
#:builder
(begin (begin
(mkdir %output) (mkdir %output)
(call-with-output-file (string-append %output "/test") (call-with-output-file (string-append %output "/test")
@ -83,13 +96,15 @@
(call-with-input-file (string-append p "/test") read)))))) (call-with-input-file (string-append p "/test") read))))))
(test-assert "GNU Hello" (test-assert "GNU Hello"
(and (package? hello) (let ((hello (package-with-explicit-inputs hello %bootstrap-inputs
(or (location? (package-location hello)) #:guile %bootstrap-guile)))
(not (package-location hello))) (and (package? hello)
(let* ((drv (package-derivation %store hello)) (or (location? (package-location hello))
(out (derivation-path->output-path drv))) (not (package-location hello)))
(and (build-derivations %store (list drv)) (let* ((drv (package-derivation %store hello))
(file-exists? (string-append out "/bin/hello")))))) (out (derivation-path->output-path drv)))
(and (build-derivations %store (list drv))
(file-exists? (string-append out "/bin/hello")))))))
(test-assert "find-packages-by-name" (test-assert "find-packages-by-name"
(match (find-packages-by-name "hello") (match (find-packages-by-name "hello")