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" | |
33594aa4 LC |
35 | (let* ((f (search-path %load-path "tests/test.drv")) |
36 | (b1 (call-with-input-file f get-bytevector-all)) | |
341c6fdd LC |
37 | (d1 (read-derivation (open-bytevector-input-port b1))) |
38 | (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>))) | |
39 | (d2 (read-derivation (open-bytevector-input-port b2)))) | |
40 | (and (equal? b1 b2) | |
41 | (equal? d1 d2)))) | |
42 | ||
fb3eec83 | 43 | (test-skip (if %store 0 2)) |
26bbbb95 LC |
44 | |
45 | (test-assert "derivation with no inputs" | |
46 | (let ((builder (add-text-to-store %store "my-builder.sh" | |
47 | "#!/bin/sh\necho hello, world\n" | |
48 | '()))) | |
49 | (store-path? (derivation %store "foo" "x86_64-linux" builder | |
50 | '() '(("HOME" . "/homeless")) '())))) | |
51 | ||
fb3eec83 LC |
52 | (test-assert "build derivation with 1 source" |
53 | (let*-values (((builder) | |
54 | (add-text-to-store %store "my-builder.sh" | |
55 | "#!/bin/sh\necho hello, world > \"$out\"\n" | |
56 | '())) | |
57 | ((drv-path drv) | |
58 | (derivation %store "foo" "x86_64-linux" | |
59 | "/bin/sh" `(,builder) | |
60 | '(("HOME" . "/homeless")) | |
61 | `((,builder)))) | |
62 | ((succeeded?) | |
63 | (build-derivations %store (list drv-path)))) | |
64 | (and succeeded? | |
65 | (let ((path (derivation-output-path | |
66 | (assoc-ref (derivation-outputs drv) "out")))) | |
67 | (string=? (call-with-input-file path read-line) | |
68 | "hello, world"))))) | |
69 | ||
341c6fdd LC |
70 | (test-end) |
71 | ||
72 | \f | |
73 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | |
74 | ||
75 | ;;; Local Variables: | |
76 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) | |
77 | ;;; End: |