gnu: vsearch: Restrict supported systems to x86_64-linux.
[guix.git] / tests / builders.scm
bloba7c3e428305d441ec8ddd276d28dc41eacb5bfab
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
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 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
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
17 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
20 (define-module (test-builders)
21   #:use-module (guix download)
22   #:use-module (guix build-system)
23   #:use-module (guix build-system gnu)
24   #:use-module (guix store)
25   #:use-module (guix utils)
26   #:use-module (guix base32)
27   #:use-module (guix derivations)
28   #:use-module (guix hash)
29   #:use-module (guix tests)
30   #:use-module ((guix packages)
31                 #:select (package-derivation package-native-search-paths))
32   #:use-module (gnu packages bootstrap)
33   #:use-module (ice-9 match)
34   #:use-module (srfi srfi-1)
35   #:use-module (srfi srfi-64))
37 ;; Test the higher-level builders.
39 (define %store
40   (open-connection-for-tests))
42 (define %bootstrap-inputs
43   ;; Use the bootstrap inputs so it doesn't take ages to run these tests.
44   ;; This still involves building Make, Diffutils, and Findutils.
45   ;; XXX: We're relying on the higher-level `package-derivations' here.
46   (and %store
47        (map (match-lambda
48              ((name package)
49               (list name (package-derivation %store package))))
50             (@@ (gnu packages commencement) %boot0-inputs))))
52 (define %bootstrap-search-paths
53   ;; Search path specifications that go with %BOOTSTRAP-INPUTS.
54   (append-map (match-lambda
55                ((name package _ ...)
56                 (package-native-search-paths package)))
57               (@@ (gnu packages commencement) %boot0-inputs)))
59 (define url-fetch*
60   (store-lower url-fetch))
63 (test-begin "builders")
65 (unless (network-reachable?) (test-skip 1))
66 (test-assert "url-fetch"
67   (let* ((url      '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
68                      "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
69          (hash     (nix-base32-string->bytevector
70                     "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
71          (drv      (url-fetch* %store url 'sha256 hash
72                                #:guile %bootstrap-guile))
73          (out-path (derivation->output-path drv)))
74     (and (build-derivations %store (list drv))
75          (file-exists? out-path)
76          (valid-path? %store out-path))))
78 (test-assert "url-fetch, file"
79   (let* ((file (search-path %load-path "guix.scm"))
80          (hash (call-with-input-file file port-sha256))
81          (out  (url-fetch* %store file 'sha256 hash)))
82     (and (file-exists? out)
83          (valid-path? %store out))))
85 (test-assert "url-fetch, file URI"
86   (let* ((file (search-path %load-path "guix.scm"))
87          (hash (call-with-input-file file port-sha256))
88          (out  (url-fetch* %store
89                            (string-append "file://" (canonicalize-path file))
90                            'sha256 hash)))
91     (and (file-exists? out)
92          (valid-path? %store out))))
94 (test-assert "gnu-build-system"
95   (build-system? gnu-build-system))
97 (when (or (not (network-reachable?)) (shebang-too-long?))
98   (test-skip 1))
99 (test-assert "gnu-build"
100   (let* ((url      "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
101          (hash     (nix-base32-string->bytevector
102                     "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
103          (tarball  (url-fetch* %store url 'sha256 hash
104                                #:guile %bootstrap-guile))
105          (build    (gnu-build %store "hello-2.8"
106                               `(("source" ,tarball)
107                                 ,@%bootstrap-inputs)
108                               #:guile %bootstrap-guile
109                               #:search-paths %bootstrap-search-paths))
110          (out      (derivation->output-path build)))
111     (and (build-derivations %store (list (pk 'hello-drv build)))
112          (valid-path? %store out)
113          (file-exists? (string-append out "/bin/hello")))))
115 (test-end "builders")
118 (exit (= (test-runner-fail-count (test-runner-current)) 0))