Commit | Line | Data |
---|---|---|
c924e541 KH |
1 | # GNU Guix --- Functional package management for GNU |
2 | # Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com> | |
3 | # Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> | |
4 | # | |
5 | # This file is part of GNU Guix. | |
6 | # | |
7 | # GNU Guix is free software; you can redistribute it and/or modify it | |
8 | # under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 3 of the License, or (at | |
10 | # your option) any later version. | |
11 | # | |
12 | # GNU Guix is distributed in the hope that it will be useful, but | |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | # | |
21 | # Test the `guix repl' command-line utility. | |
22 | # | |
23 | ||
24 | guix repl --version | |
25 | ||
26 | test_directory="`mktemp -d`" | |
27 | export test_directory | |
28 | trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT | |
29 | ||
30 | tmpfile="$test_directory/foo.scm" | |
31 | rm -f "$tmpfile" | |
32 | trap 'rm -f "$tmpfile"' EXIT | |
33 | ||
34 | module_dir="t-guix-repl-$$" | |
35 | mkdir "$module_dir" | |
36 | trap 'rm -rf "$module_dir"' EXIT | |
37 | ||
38 | ||
39 | cat > "$tmpfile"<<EOF | |
40 | (use-modules (guix packages) | |
41 | (gnu packages base)) | |
42 | ||
43 | (format #t "~a\n" (package-name coreutils)) | |
44 | EOF | |
45 | ||
46 | test "`guix repl "$tmpfile"`" = "coreutils" | |
47 | ||
d7f7ed39 KH |
48 | # Make sure that the file can also be loaded when passed as a relative file |
49 | # name. | |
50 | (cd "$(dirname "$tmpfile")"; test "$(guix repl "$(basename "$tmpfile")")" = "coreutils") | |
51 | ||
c924e541 KH |
52 | |
53 | cat > "$module_dir/foo.scm"<<EOF | |
54 | (define-module (foo) | |
55 | #:use-module (guix packages) | |
56 | #:use-module (gnu packages base)) | |
57 | ||
58 | (define-public dummy | |
59 | (package (inherit hello) | |
60 | (name "dummy") | |
61 | (version "42") | |
62 | (synopsis "dummy package") | |
63 | (description "dummy package. Only used for testing purposes."))) | |
64 | EOF | |
65 | ||
66 | cat > "$tmpfile"<<EOF | |
67 | (use-modules (guix packages) | |
68 | (foo)) | |
69 | ||
70 | (format #t "~a\n" (package-version dummy)) | |
71 | EOF | |
72 | ||
73 | test "`guix repl "$tmpfile" -L "$module_dir"`" = "42" | |
74 | ||
75 | cat > "$tmpfile"<<EOF | |
76 | (format #t "~a\n" (cdr (command-line))) | |
77 | EOF | |
78 | ||
79 | test "`guix repl -- "$tmpfile" -a b --input=foo.txt`" = "(-a b --input=foo.txt)" | |
80 | ||
81 | cat > "$tmpfile"<<EOF | |
82 | #!$(type -P env) -S guix repl -- | |
83 | !# | |
84 | (format #t "~a\n" (cdr (command-line))) | |
85 | EOF | |
86 | chmod 755 $tmpfile | |
87 | ||
88 | test "`"$tmpfile" -a b --input=foo.txt`" = "(-a b --input=foo.txt)" |