gnu: r-wgcna: Move to (gnu packages bioconductor).
[jackhill/guix/guix.git] / tests / builders.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2019 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/>.
18
19
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 (gcrypt hash)
29 #:use-module (guix tests)
30 #:use-module ((guix packages)
31 #:select (package?
32 package-derivation package-native-search-paths))
33 #:use-module (gnu packages bootstrap)
34 #:use-module (ice-9 match)
35 #:use-module (srfi srfi-1)
36 #:use-module (srfi srfi-64))
37
38 ;; Test the higher-level builders.
39
40 (define %store
41 (open-connection-for-tests))
42
43 (define url-fetch*
44 (store-lower url-fetch))
45
46 \f
47 (test-begin "builders")
48
49 (unless (network-reachable?) (test-skip 1))
50 (test-assert "url-fetch"
51 (let* ((url '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
52 "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
53 (hash (nix-base32-string->bytevector
54 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
55 (drv (url-fetch* %store url 'sha256 hash
56 #:guile %bootstrap-guile))
57 (out-path (derivation->output-path drv)))
58 (and (build-derivations %store (list drv))
59 (file-exists? out-path)
60 (valid-path? %store out-path))))
61
62 (test-assert "url-fetch, file"
63 (let* ((file (search-path %load-path "guix.scm"))
64 (hash (call-with-input-file file port-sha256))
65 (out (url-fetch* %store file 'sha256 hash)))
66 (and (file-exists? out)
67 (valid-path? %store out))))
68
69 (test-assert "url-fetch, file URI"
70 (let* ((file (search-path %load-path "guix.scm"))
71 (hash (call-with-input-file file port-sha256))
72 (out (url-fetch* %store
73 (string-append "file://" (canonicalize-path file))
74 'sha256 hash)))
75 (and (file-exists? out)
76 (valid-path? %store out))))
77
78 (test-assert "gnu-build-system"
79 (build-system? gnu-build-system))
80
81 (test-end "builders")