diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2012-10-06 01:24:46 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2012-10-07 22:24:59 +0200 |
| commit | 14da91e2f0de4c8a7e1f3b706cc5d961030ff190 (patch) | |
| tree | a48c033a6b5e74aa195471423f9881874b2622b0 | |
| parent | 81c7948d9acd3e203e5fd7185dbead33c11d4a92 (diff) | |
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.
| -rw-r--r-- | tests/builders.scm | 18 | ||||
| -rw-r--r-- | tests/packages.scm | 31 |
2 files changed, 40 insertions, 9 deletions
diff --git a/tests/builders.scm b/tests/builders.scm index 762944ba73a..629c88c1e53 100644 --- a/tests/builders.scm +++ b/tests/builders.scm | |||
| @@ -32,6 +32,18 @@ | |||
| 32 | (define %store | 32 | (define %store |
| 33 | (false-if-exception (open-connection))) | 33 | (false-if-exception (open-connection))) |
| 34 | 34 | ||
| 35 | (define %bootstrap-inputs | ||
| 36 | ;; Derivations taken from Nixpkgs, so that the initial tests don't | ||
| 37 | ;; take forever. | ||
| 38 | (and (file-exists? (%nixpkgs-directory)) | ||
| 39 | `(("make" ,(nixpkgs-derivation "gnumake")) | ||
| 40 | ("diffutils" ,(nixpkgs-derivation "diffutils")) | ||
| 41 | ,@(@@ (distro packages base) %bootstrap-inputs)))) | ||
| 42 | |||
| 43 | (define %bootstrap-guile | ||
| 44 | (@@ (distro packages base) %bootstrap-guile)) | ||
| 45 | |||
| 46 | |||
| 35 | (test-begin "builders") | 47 | (test-begin "builders") |
| 36 | 48 | ||
| 37 | (test-assert "http-fetch" | 49 | (test-assert "http-fetch" |
| @@ -48,13 +60,17 @@ | |||
| 48 | (and (build-system? gnu-build-system) | 60 | (and (build-system? gnu-build-system) |
| 49 | (eq? gnu-build (build-system-builder gnu-build-system)))) | 61 | (eq? gnu-build (build-system-builder gnu-build-system)))) |
| 50 | 62 | ||
| 63 | (test-skip (if (file-exists? (%nixpkgs-directory)) 1 0)) | ||
| 64 | |||
| 51 | (test-assert "gnu-build" | 65 | (test-assert "gnu-build" |
| 52 | (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz") | 66 | (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz") |
| 53 | (hash (nix-base32-string->bytevector | 67 | (hash (nix-base32-string->bytevector |
| 54 | "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) | 68 | "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) |
| 55 | (tarball (http-fetch %store url 'sha256 hash)) | 69 | (tarball (http-fetch %store url 'sha256 hash)) |
| 56 | (build (gnu-build %store "hello-2.8" tarball | 70 | (build (gnu-build %store "hello-2.8" tarball |
| 57 | `(("gawk" ,(nixpkgs-derivation "gawk"))))) | 71 | %bootstrap-inputs |
| 72 | #:implicit-inputs? #f | ||
| 73 | #:guile %bootstrap-guile)) | ||
| 58 | (out (derivation-path->output-path build))) | 74 | (out (derivation-path->output-path build))) |
| 59 | (and (build-derivations %store (list (pk 'hello-drv build))) | 75 | (and (build-derivations %store (list (pk 'hello-drv build))) |
| 60 | (valid-path? %store out) | 76 | (valid-path? %store out) |
diff --git a/tests/packages.scm b/tests/packages.scm index 20f586e4494..1319bf8634c 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -35,6 +35,18 @@ | |||
| 35 | (define %store | 35 | (define %store |
| 36 | (false-if-exception (open-connection))) | 36 | (false-if-exception (open-connection))) |
| 37 | 37 | ||
| 38 | (define %bootstrap-inputs | ||
| 39 | ;; Derivations taken from Nixpkgs, so that the initial tests don't | ||
| 40 | ;; take forever. | ||
| 41 | (and (file-exists? (%nixpkgs-directory)) | ||
| 42 | `(("make" ,(nixpkgs-derivation "gnumake")) | ||
| 43 | ("diffutils" ,(nixpkgs-derivation "diffutils")) | ||
| 44 | ,@(@@ (distro packages base) %bootstrap-inputs)))) | ||
| 45 | |||
| 46 | (define %bootstrap-guile | ||
| 47 | (@@ (distro packages base) %bootstrap-guile)) | ||
| 48 | |||
| 49 | |||
| 38 | (test-begin "packages") | 50 | (test-begin "packages") |
| 39 | 51 | ||
| 40 | (define-syntax-rule (dummy-package name* extra-fields ...) | 52 | (define-syntax-rule (dummy-package name* extra-fields ...) |
| @@ -70,7 +82,8 @@ | |||
| 70 | (build-system trivial-build-system) | 82 | (build-system trivial-build-system) |
| 71 | (source #f) | 83 | (source #f) |
| 72 | (arguments | 84 | (arguments |
| 73 | '(#:builder | 85 | `(#:guile ,%bootstrap-guile |
| 86 | #:builder | ||
| 74 | (begin | 87 | (begin |
| 75 | (mkdir %output) | 88 | (mkdir %output) |
| 76 | (call-with-output-file (string-append %output "/test") | 89 | (call-with-output-file (string-append %output "/test") |
| @@ -83,13 +96,15 @@ | |||
| 83 | (call-with-input-file (string-append p "/test") read)))))) | 96 | (call-with-input-file (string-append p "/test") read)))))) |
| 84 | 97 | ||
| 85 | (test-assert "GNU Hello" | 98 | (test-assert "GNU Hello" |
| 86 | (and (package? hello) | 99 | (let ((hello (package-with-explicit-inputs hello %bootstrap-inputs |
| 87 | (or (location? (package-location hello)) | 100 | #:guile %bootstrap-guile))) |
| 88 | (not (package-location hello))) | 101 | (and (package? hello) |
| 89 | (let* ((drv (package-derivation %store hello)) | 102 | (or (location? (package-location hello)) |
| 90 | (out (derivation-path->output-path drv))) | 103 | (not (package-location hello))) |
| 91 | (and (build-derivations %store (list drv)) | 104 | (let* ((drv (package-derivation %store hello)) |
| 92 | (file-exists? (string-append out "/bin/hello")))))) | 105 | (out (derivation-path->output-path drv))) |
| 106 | (and (build-derivations %store (list drv)) | ||
| 107 | (file-exists? (string-append out "/bin/hello"))))))) | ||
| 93 | 108 | ||
| 94 | (test-assert "find-packages-by-name" | 109 | (test-assert "find-packages-by-name" |
| 95 | (match (find-packages-by-name "hello") | 110 | (match (find-packages-by-name "hello") |
