Commit | Line | Data |
---|---|---|
3eb98237 LC |
1 | ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- |
2 | ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> | |
3 | ;;; | |
4 | ;;; This file is part of Guix. | |
5 | ;;; | |
6 | ;;; 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 | ;;; 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 Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | ||
20 | (define-module (test-builders) | |
21 | #:use-module (guix http) | |
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) | |
26 | #:use-module (guix derivations) | |
27 | #:use-module (srfi srfi-1) | |
28 | #:use-module (srfi srfi-64)) | |
29 | ||
30 | ;; Test the higher-level builders. | |
31 | ||
32 | (define %store | |
33 | (false-if-exception (open-connection))) | |
34 | ||
14da91e2 LC |
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 | \f | |
3eb98237 LC |
47 | (test-begin "builders") |
48 | ||
49 | (test-assert "http-fetch" | |
50 | (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz") | |
51 | (hash (nix-base32-string->bytevector | |
52 | "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) | |
31ef99a8 LC |
53 | (drv-path (http-fetch %store url 'sha256 hash)) |
54 | (out-path (derivation-path->output-path drv-path))) | |
3eb98237 | 55 | (and (build-derivations %store (list drv-path)) |
31ef99a8 LC |
56 | (file-exists? out-path) |
57 | (valid-path? %store out-path)))) | |
3eb98237 | 58 | |
208f7cd1 LC |
59 | (test-assert "gnu-build-system" |
60 | (and (build-system? gnu-build-system) | |
61 | (eq? gnu-build (build-system-builder gnu-build-system)))) | |
62 | ||
14da91e2 LC |
63 | (test-skip (if (file-exists? (%nixpkgs-directory)) 1 0)) |
64 | ||
c36db98c LC |
65 | (test-assert "gnu-build" |
66 | (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz") | |
67 | (hash (nix-base32-string->bytevector | |
68 | "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")) | |
69 | (tarball (http-fetch %store url 'sha256 hash)) | |
70 | (build (gnu-build %store "hello-2.8" tarball | |
14da91e2 LC |
71 | %bootstrap-inputs |
72 | #:implicit-inputs? #f | |
73 | #:guile %bootstrap-guile)) | |
31ef99a8 | 74 | (out (derivation-path->output-path build))) |
c36db98c | 75 | (and (build-derivations %store (list (pk 'hello-drv build))) |
31ef99a8 LC |
76 | (valid-path? %store out) |
77 | (file-exists? (string-append out "/bin/hello"))))) | |
c36db98c | 78 | |
3eb98237 LC |
79 | (test-end "builders") |
80 | ||
81 | \f | |
82 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | |
83 | ||
84 | ;;; Local Variables: | |
85 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) | |
86 | ;;; End: |