inferior: Add 'inferior-package-derivation'.
[jackhill/guix/guix.git] / tests / inferior.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU 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 ;;; GNU 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (test-inferior)
20 #:use-module (guix tests)
21 #:use-module (guix inferior)
22 #:use-module (guix packages)
23 #:use-module (guix store)
24 #:use-module (guix derivations)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages bootstrap)
27 #:use-module (srfi srfi-1)
28 #:use-module (srfi srfi-64))
29
30 (define %top-srcdir
31 (dirname (search-path %load-path "guix.scm")))
32
33 (define %top-builddir
34 (dirname (search-path %load-compiled-path "guix.go")))
35
36 (define %store
37 (open-connection-for-tests))
38
39 \f
40 (test-begin "inferior")
41
42 (test-equal "open-inferior"
43 '(42 #t)
44 (let ((inferior (open-inferior %top-builddir
45 #:command "scripts/guix")))
46 (and (inferior? inferior)
47 (let ((a (inferior-eval '(apply * '(6 7)) inferior))
48 (b (inferior-eval '(@ (gnu packages base) coreutils)
49 inferior)))
50 (close-inferior inferior)
51 (list a (inferior-object? b))))))
52
53 (test-equal "inferior-packages"
54 (take (sort (fold-packages (lambda (package lst)
55 (cons (list (package-name package)
56 (package-version package)
57 (package-home-page package)
58 (package-location package))
59 lst))
60 '())
61 (lambda (x y)
62 (string<? (car x) (car y))))
63 10)
64 (let* ((inferior (open-inferior %top-builddir
65 #:command "scripts/guix"))
66 (packages (inferior-packages inferior)))
67 (and (every string? (map inferior-package-synopsis packages))
68 (let ()
69 (define result
70 (take (sort (map (lambda (package)
71 (list (inferior-package-name package)
72 (inferior-package-version package)
73 (inferior-package-home-page package)
74 (inferior-package-location package)))
75 packages)
76 (lambda (x y)
77 (string<? (car x) (car y))))
78 10))
79 (close-inferior inferior)
80 result))))
81
82 (test-equal "inferior-package-derivation"
83 (map derivation-file-name
84 (list (package-derivation %store %bootstrap-guile "x86_64-linux")
85 (package-derivation %store %bootstrap-guile "armhf-linux")))
86 (let* ((inferior (open-inferior %top-builddir
87 #:command "scripts/guix"))
88 (packages (inferior-packages inferior))
89 (guile (find (lambda (package)
90 (string=? (package-name %bootstrap-guile)
91 (inferior-package-name package)))
92 packages)))
93 (map derivation-file-name
94 (list (inferior-package-derivation %store guile "x86_64-linux")
95 (inferior-package-derivation %store guile "armhf-linux")))))
96
97 (test-end "inferior")