Commit | Line | Data |
---|---|---|
233e7676 LC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org> | |
3eb98237 | 3 | ;;; |
233e7676 | 4 | ;;; This file is part of GNU Guix. |
3eb98237 | 5 | ;;; |
233e7676 | 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
3eb98237 LC |
7 | ;;; under the terms of the GNU General Public License as published by |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
233e7676 | 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
3eb98237 LC |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
3eb98237 LC |
18 | |
19 | ||
20 | (define-module (test-builders) | |
62cab99c | 21 | #:use-module (guix download) |
208f7cd1 LC |
22 | #:use-module (guix build-system) |
23 | #:use-module (guix build-system gnu) | |
3eb98237 LC |
24 | #:use-module (guix store) |
25 | #:use-module (guix utils) | |
ddc29a78 | 26 | #:use-module (guix base32) |
3eb98237 | 27 | #:use-module (guix derivations) |
8f3ecbd7 | 28 | #:use-module ((guix packages) #:select (package-derivation)) |
1ffa7090 | 29 | #:use-module (gnu packages bootstrap) |
8f3ecbd7 | 30 | #:use-module (ice-9 match) |
3eb98237 LC |
31 | #:use-module (srfi srfi-1) |
32 | #:use-module (srfi srfi-64)) | |
33 | ||
34 | ;; Test the higher-level builders. | |
35 | ||
36 | (define %store | |
37 | (false-if-exception (open-connection))) | |
38 | ||
81dbd783 LC |
39 | (when %store |
40 | ;; Make sure we build everything by ourselves. | |
41 | (set-build-options %store #:use-substitutes? #f)) | |
42 | ||
14da91e2 | 43 | (define %bootstrap-inputs |
8f3ecbd7 LC |
44 | ;; Use the bootstrap inputs so it doesn't take ages to run these tests. |
45 | ;; This still involves building Make, Diffutils, and Findutils. | |
46 | ;; XXX: We're relying on the higher-level `package-derivations' here. | |
47 | (and %store | |
48 | (map (match-lambda | |
49 | ((name package) | |
50 | (list name (package-derivation %store package)))) | |
1ffa7090 | 51 | (@@ (gnu packages base) %boot0-inputs)))) |
14da91e2 | 52 | |
ad1ebab3 LC |
53 | (define network-reachable? |
54 | (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))) | |
55 | ||
14da91e2 | 56 | \f |
3eb98237 LC |
57 | (test-begin "builders") |
58 | ||
ad1ebab3 | 59 | (unless network-reachable? (test-skip 1)) |
62cab99c LC |
60 | (test-assert "url-fetch" |
61 | (let* ((url '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz" | |
62 | "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")) | |
63 | (hash (nix-base32-string->bytevector | |
64 | "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) | |
92b8d1ea LC |
65 | (drv-path (url-fetch %store url 'sha256 hash |
66 | #:guile %bootstrap-guile)) | |
62cab99c LC |
67 | (out-path (derivation-path->output-path drv-path))) |
68 | (and (build-derivations %store (list drv-path)) | |
69 | (file-exists? out-path) | |
70 | (valid-path? %store out-path)))) | |
3eb98237 | 71 | |
208f7cd1 LC |
72 | (test-assert "gnu-build-system" |
73 | (and (build-system? gnu-build-system) | |
74 | (eq? gnu-build (build-system-builder gnu-build-system)))) | |
75 | ||
ad1ebab3 | 76 | (unless network-reachable? (test-skip 1)) |
c36db98c LC |
77 | (test-assert "gnu-build" |
78 | (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz") | |
79 | (hash (nix-base32-string->bytevector | |
80 | "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) | |
92b8d1ea LC |
81 | (tarball (url-fetch %store url 'sha256 hash |
82 | #:guile %bootstrap-guile)) | |
c36db98c | 83 | (build (gnu-build %store "hello-2.8" tarball |
14da91e2 LC |
84 | %bootstrap-inputs |
85 | #:implicit-inputs? #f | |
86 | #:guile %bootstrap-guile)) | |
31ef99a8 | 87 | (out (derivation-path->output-path build))) |
c36db98c | 88 | (and (build-derivations %store (list (pk 'hello-drv build))) |
31ef99a8 LC |
89 | (valid-path? %store out) |
90 | (file-exists? (string-append out "/bin/hello"))))) | |
c36db98c | 91 | |
3eb98237 LC |
92 | (test-end "builders") |
93 | ||
94 | \f | |
95 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) |