Add (guix inferior) and (guix scripts repl).
[jackhill/guix/guix.git] / tests / inferior.scm
CommitLineData
2ca299ca
LC
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 inferior)
21 #:use-module (guix packages)
22 #:use-module (gnu packages)
23 #:use-module (srfi srfi-1)
24 #:use-module (srfi srfi-64))
25
26(define %top-srcdir
27 (dirname (search-path %load-path "guix.scm")))
28
29(define %top-builddir
30 (dirname (search-path %load-compiled-path "guix.go")))
31
32\f
33(test-begin "inferior")
34
35(test-equal "open-inferior"
36 '(42 #t)
37 (let ((inferior (open-inferior %top-builddir
38 #:command "scripts/guix")))
39 (and (inferior? inferior)
40 (let ((a (inferior-eval '(apply * '(6 7)) inferior))
41 (b (inferior-eval '(@ (gnu packages base) coreutils)
42 inferior)))
43 (close-inferior inferior)
44 (list a (inferior-object? b))))))
45
46(test-equal "inferior-packages"
47 (take (sort (fold-packages (lambda (package lst)
48 (alist-cons (package-name package)
49 (package-version package)
50 lst))
51 '())
52 (lambda (x y)
53 (string<? (car x) (car y))))
54 10)
55 (let* ((inferior (open-inferior %top-builddir
56 #:command "scripts/guix"))
57 (packages (inferior-packages inferior)))
58 (and (every string? (map inferior-package-synopsis packages))
59 (begin
60 (close-inferior inferior)
61 (take (sort (map (lambda (package)
62 (cons (inferior-package-name package)
63 (inferior-package-version package)))
64 packages)
65 (lambda (x y)
66 (string<? (car x) (car y))))
67 10)))))
68
69(test-end "inferior")