Commit | Line | Data |
---|---|---|
341c6fdd 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-derivations) | |
21 | #:use-module (guix derivations) | |
26bbbb95 | 22 | #:use-module (guix store) |
fb3eec83 | 23 | #:use-module (srfi srfi-11) |
341c6fdd LC |
24 | #:use-module (srfi srfi-26) |
25 | #:use-module (srfi srfi-64) | |
fb3eec83 LC |
26 | #:use-module (rnrs io ports) |
27 | #:use-module (ice-9 rdelim)) | |
341c6fdd | 28 | |
26bbbb95 LC |
29 | (define %store |
30 | (false-if-exception (open-connection))) | |
31 | ||
341c6fdd LC |
32 | (test-begin "derivations") |
33 | ||
34 | (test-assert "parse & export" | |
35 | (let* ((b1 (call-with-input-file "test.drv" get-bytevector-all)) | |
36 | (d1 (read-derivation (open-bytevector-input-port b1))) | |
37 | (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>))) | |
38 | (d2 (read-derivation (open-bytevector-input-port b2)))) | |
39 | (and (equal? b1 b2) | |
40 | (equal? d1 d2)))) | |
41 | ||
fb3eec83 | 42 | (test-skip (if %store 0 2)) |
26bbbb95 LC |
43 | |
44 | (test-assert "derivation with no inputs" | |
45 | (let ((builder (add-text-to-store %store "my-builder.sh" | |
46 | "#!/bin/sh\necho hello, world\n" | |
47 | '()))) | |
48 | (store-path? (derivation %store "foo" "x86_64-linux" builder | |
49 | '() '(("HOME" . "/homeless")) '())))) | |
50 | ||
fb3eec83 LC |
51 | (test-assert "build derivation with 1 source" |
52 | (let*-values (((builder) | |
53 | (add-text-to-store %store "my-builder.sh" | |
54 | "#!/bin/sh\necho hello, world > \"$out\"\n" | |
55 | '())) | |
56 | ((drv-path drv) | |
57 | (derivation %store "foo" "x86_64-linux" | |
58 | "/bin/sh" `(,builder) | |
59 | '(("HOME" . "/homeless")) | |
60 | `((,builder)))) | |
61 | ((succeeded?) | |
62 | (build-derivations %store (list drv-path)))) | |
63 | (and succeeded? | |
64 | (let ((path (derivation-output-path | |
65 | (assoc-ref (derivation-outputs drv) "out")))) | |
66 | (string=? (call-with-input-file path read-line) | |
67 | "hello, world"))))) | |
68 | ||
341c6fdd LC |
69 | (test-end) |
70 | ||
71 | \f | |
72 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | |
73 | ||
74 | ;;; Local Variables: | |
75 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) | |
76 | ;;; End: |