Commit | Line | Data |
---|---|---|
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) | |
9daf046c | 20 | #:use-module (guix tests) |
2ca299ca LC |
21 | #:use-module (guix inferior) |
22 | #:use-module (guix packages) | |
9daf046c LC |
23 | #:use-module (guix store) |
24 | #:use-module (guix derivations) | |
2ca299ca | 25 | #:use-module (gnu packages) |
9daf046c | 26 | #:use-module (gnu packages bootstrap) |
2ca299ca LC |
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 | ||
9daf046c LC |
36 | (define %store |
37 | (open-connection-for-tests)) | |
38 | ||
2ca299ca LC |
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) | |
7e1d2290 | 55 | (cons (list (package-name package) |
2ca299ca | 56 | (package-version package) |
7e1d2290 LC |
57 | (package-home-page package) |
58 | (package-location package)) | |
59 | lst)) | |
2ca299ca LC |
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)) | |
7e1d2290 LC |
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)) | |
2ca299ca | 79 | (close-inferior inferior) |
7e1d2290 | 80 | result)))) |
2ca299ca | 81 | |
e1a4ffda LC |
82 | (test-equal "lookup-inferior-packages" |
83 | (let ((->list (lambda (package) | |
84 | (list (package-name package) | |
85 | (package-version package) | |
86 | (package-location package))))) | |
87 | (list (map ->list (find-packages-by-name "guile" #f)) | |
88 | (map ->list (find-packages-by-name "guile" "2.2")))) | |
89 | (let* ((inferior (open-inferior %top-builddir | |
90 | #:command "scripts/guix")) | |
91 | (->list (lambda (package) | |
92 | (list (inferior-package-name package) | |
93 | (inferior-package-version package) | |
94 | (inferior-package-location package)))) | |
95 | (lst1 (map ->list | |
96 | (lookup-inferior-packages inferior "guile"))) | |
97 | (lst2 (map ->list | |
98 | (lookup-inferior-packages inferior | |
99 | "guile" "2.2")))) | |
100 | (close-inferior inferior) | |
101 | (list lst1 lst2))) | |
102 | ||
103 | (test-assert "lookup-inferior-packages and eq?-ness" | |
104 | (let* ((inferior (open-inferior %top-builddir | |
105 | #:command "scripts/guix")) | |
106 | (lst1 (lookup-inferior-packages inferior "guile")) | |
107 | (lst2 (lookup-inferior-packages inferior "guile"))) | |
108 | (close-inferior inferior) | |
109 | (every eq? lst1 lst2))) | |
110 | ||
9daf046c LC |
111 | (test-equal "inferior-package-derivation" |
112 | (map derivation-file-name | |
113 | (list (package-derivation %store %bootstrap-guile "x86_64-linux") | |
114 | (package-derivation %store %bootstrap-guile "armhf-linux"))) | |
115 | (let* ((inferior (open-inferior %top-builddir | |
116 | #:command "scripts/guix")) | |
117 | (packages (inferior-packages inferior)) | |
118 | (guile (find (lambda (package) | |
119 | (string=? (package-name %bootstrap-guile) | |
120 | (inferior-package-name package))) | |
121 | packages))) | |
122 | (map derivation-file-name | |
123 | (list (inferior-package-derivation %store guile "x86_64-linux") | |
124 | (inferior-package-derivation %store guile "armhf-linux"))))) | |
125 | ||
2ca299ca | 126 | (test-end "inferior") |