Add the usual top-level files.
[jackhill/guix/guix.git] / tests / derivations.scm
CommitLineData
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)
341c6fdd
LC
23 #:use-module (srfi srfi-26)
24 #:use-module (srfi srfi-64)
25 #:use-module (rnrs io ports))
26
26bbbb95
LC
27(define %store
28 (false-if-exception (open-connection)))
29
341c6fdd
LC
30(test-begin "derivations")
31
32(test-assert "parse & export"
33 (let* ((b1 (call-with-input-file "test.drv" get-bytevector-all))
34 (d1 (read-derivation (open-bytevector-input-port b1)))
35 (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>)))
36 (d2 (read-derivation (open-bytevector-input-port b2))))
37 (and (equal? b1 b2)
38 (equal? d1 d2))))
39
26bbbb95
LC
40(test-skip (if %store 0 1))
41
42(test-assert "derivation with no inputs"
43 (let ((builder (add-text-to-store %store "my-builder.sh"
44 "#!/bin/sh\necho hello, world\n"
45 '())))
46 (store-path? (derivation %store "foo" "x86_64-linux" builder
47 '() '(("HOME" . "/homeless")) '()))))
48
341c6fdd
LC
49(test-end)
50
51\f
52(exit (= (test-runner-fail-count (test-runner-current)) 0))
53
54;;; Local Variables:
55;;; eval: (put 'test-assert 'scheme-indent-function 1)
56;;; End: