summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-10-29 22:39:46 +0100
committerLudovic Courtès <ludo@gnu.org>2012-10-29 22:39:46 +0100
commitc8c88afaa14f760ec71ffb2ef0d712b7e42cc71f (patch)
tree3d7a2a037683dc02fa55fc27e575ae1483da7fa0 /tests
parent48da001fd96bb9ff063b512666f5122b83bc210d (diff)
Add (guix build union).
* guix/build/union.scm, tests/union.scm: New files. * Makefile.am (MODULES): Add `guix/build/union.scm'. (TESTS): Add `tests/union.scm'.
Diffstat (limited to 'tests')
-rw-r--r--tests/union.scm103
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/union.scm b/tests/union.scm
new file mode 100644
index 00000000000..f8a58d59527
--- /dev/null
+++ b/tests/union.scm
@@ -0,0 +1,103 @@
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-union)
21 #:use-module (guix store)
22 #:use-module (guix utils)
23 #:use-module (guix derivations)
24 #:use-module (guix packages)
25 #:use-module (guix build union)
26 #:use-module ((guix build utils)
27 #:select (with-directory-excursion directory-exists?))
28 #:use-module (srfi srfi-64)
29 #:use-module (ice-9 match))
30
31;; Exercise the (guix build union) module.
32
33(define %store
34 (false-if-exception (open-connection)))
35
36(define %bootstrap-guile
37 (@@ (distro packages base) %bootstrap-guile))
38
39(when %store
40 ;; By default, use %BOOTSTRAP-GUILE for the current system.
41 (let ((drv (package-derivation %store %bootstrap-guile)))
42 (%guile-for-build drv)))
43
44
45(test-begin "union")
46
47(test-equal "tree-union, empty"
48 '()
49 (tree-union '()))
50
51(test-equal "tree-union, leaves only"
52 '(a b c d)
53 (tree-union '(a b c d)))
54
55(test-equal "tree-union, simple"
56 '((bin ls touch make awk gawk))
57 (tree-union '((bin ls touch)
58 (bin make)
59 (bin awk gawk))))
60
61(test-equal "tree-union, several levels"
62 '((share (doc (make README) (coreutils README)))
63 (bin ls touch make))
64 (tree-union '((bin ls touch)
65 (share (doc (coreutils README)))
66 (bin make)
67 (share (doc (make README))))))
68
69(test-skip (if %store 0 1))
70
71(test-assert "union-build"
72 (let* ((inputs (map (match-lambda
73 ((name package)
74 `(,name ,(package-derivation %store package))))
75 (@@ (distro packages base) %bootstrap-inputs)))
76 (builder `(begin
77 (use-modules (guix build union))
78 (union-build (assoc-ref %outputs "out")
79 (map cdr %build-inputs))))
80 (drv
81 (build-expression->derivation %store "union-test"
82 (%current-system)
83 builder inputs
84 #:modules '((guix build union)))))
85 (and (build-derivations %store (list (pk 'drv drv)))
86 (with-directory-excursion (derivation-path->output-path drv)
87 (and (file-exists? "bin/touch")
88 (file-exists? "bin/gcc")
89 (file-exists? "bin/ld")
90 (file-exists? "lib/libc.so")
91 (directory-exists? "lib/gcc")
92 (file-exists? "include/unistd.h"))))))
93
94(test-end)
95
96
97(exit (= (test-runner-fail-count (test-runner-current)) 0))
98
99;;; Local Variables:
100;;; eval: (put 'test-assert 'scheme-indent-function 1)
101;;; eval: (put 'test-equal 'scheme-indent-function 1)
102;;; eval: (put 'call-with-input-string 'scheme-indent-function 1)
103;;; End: