emacs: Add support for modifying options during operation confirmation.
[jackhill/guix/guix.git] / tests / builders.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
c1bc358f 2;;; Copyright © 2012, 2013, 2014 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)
c1bc358f 28 #:use-module (guix tests)
7a88ad6b
LC
29 #:use-module ((guix packages)
30 #:select (package-derivation package-native-search-paths))
1ffa7090 31 #:use-module (gnu packages bootstrap)
8f3ecbd7 32 #:use-module (ice-9 match)
3eb98237
LC
33 #:use-module (srfi srfi-1)
34 #:use-module (srfi srfi-64))
35
36;; Test the higher-level builders.
37
38(define %store
c1bc358f 39 (open-connection-for-tests))
81dbd783 40
14da91e2 41(define %bootstrap-inputs
8f3ecbd7
LC
42 ;; Use the bootstrap inputs so it doesn't take ages to run these tests.
43 ;; This still involves building Make, Diffutils, and Findutils.
44 ;; XXX: We're relying on the higher-level `package-derivations' here.
45 (and %store
46 (map (match-lambda
47 ((name package)
48 (list name (package-derivation %store package))))
bdb36958 49 (@@ (gnu packages commencement) %boot0-inputs))))
14da91e2 50
7a88ad6b
LC
51(define %bootstrap-search-paths
52 ;; Search path specifications that go with %BOOTSTRAP-INPUTS.
53 (append-map (match-lambda
54 ((name package _ ...)
55 (package-native-search-paths package)))
bdb36958 56 (@@ (gnu packages commencement) %boot0-inputs)))
7a88ad6b 57
ad1ebab3
LC
58(define network-reachable?
59 (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
60
14da91e2 61\f
3eb98237
LC
62(test-begin "builders")
63
ad1ebab3 64(unless network-reachable? (test-skip 1))
62cab99c
LC
65(test-assert "url-fetch"
66 (let* ((url '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
67 "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
68 (hash (nix-base32-string->bytevector
69 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
59688fc4 70 (drv (url-fetch %store url 'sha256 hash
92b8d1ea 71 #:guile %bootstrap-guile))
59688fc4
LC
72 (out-path (derivation->output-path drv)))
73 (and (build-derivations %store (list drv))
62cab99c
LC
74 (file-exists? out-path)
75 (valid-path? %store out-path))))
3eb98237 76
208f7cd1
LC
77(test-assert "gnu-build-system"
78 (and (build-system? gnu-build-system)
79 (eq? gnu-build (build-system-builder gnu-build-system))))
80
ad1ebab3 81(unless network-reachable? (test-skip 1))
c36db98c
LC
82(test-assert "gnu-build"
83 (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
84 (hash (nix-base32-string->bytevector
85 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
92b8d1ea
LC
86 (tarball (url-fetch %store url 'sha256 hash
87 #:guile %bootstrap-guile))
c36db98c 88 (build (gnu-build %store "hello-2.8" tarball
14da91e2
LC
89 %bootstrap-inputs
90 #:implicit-inputs? #f
7a88ad6b
LC
91 #:guile %bootstrap-guile
92 #:search-paths %bootstrap-search-paths))
59688fc4 93 (out (derivation->output-path build)))
c36db98c 94 (and (build-derivations %store (list (pk 'hello-drv build)))
31ef99a8
LC
95 (valid-path? %store out)
96 (file-exists? (string-append out "/bin/hello")))))
c36db98c 97
3eb98237
LC
98(test-end "builders")
99
100\f
101(exit (= (test-runner-fail-count (test-runner-current)) 0))