summaryrefslogtreecommitdiff
path: root/tests/guix-repl.sh
diff options
context:
space:
mode:
authorKonrad Hinsen <konrad.hinsen@fastmail.net>2020-06-14 09:00:12 +0200
committerLudovic Courtès <ludo@gnu.org>2020-06-14 23:02:36 +0200
commitc924e541390f9595d819edc33c19d979917c15ec (patch)
tree37d4854ff1f2b4b20c4826af1e6b76161b21a123 /tests/guix-repl.sh
parent1b917f99b5fb2968a381ef0acd43db7f711f2db9 (diff)
guix repl: Add script execution.
* guix/scripts/repl.scm: Add filename options for script execution. * doc/guix.texi (Invoking guix repl): Document it. * tests/guix-repl.sh: Test it. * Makefile.am: (SH_TESTS): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/guix-repl.sh')
-rw-r--r--tests/guix-repl.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/guix-repl.sh b/tests/guix-repl.sh
new file mode 100644
index 00000000000..e1c2b8241fe
--- /dev/null
+++ b/tests/guix-repl.sh
@@ -0,0 +1,84 @@
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
24guix repl --version
25
26test_directory="`mktemp -d`"
27export test_directory
28trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
29
30tmpfile="$test_directory/foo.scm"
31rm -f "$tmpfile"
32trap 'rm -f "$tmpfile"' EXIT
33
34module_dir="t-guix-repl-$$"
35mkdir "$module_dir"
36trap 'rm -rf "$module_dir"' EXIT
37
38
39cat > "$tmpfile"<<EOF
40(use-modules (guix packages)
41 (gnu packages base))
42
43(format #t "~a\n" (package-name coreutils))
44EOF
45
46test "`guix repl "$tmpfile"`" = "coreutils"
47
48
49cat > "$module_dir/foo.scm"<<EOF
50(define-module (foo)
51 #:use-module (guix packages)
52 #:use-module (gnu packages base))
53
54(define-public dummy
55 (package (inherit hello)
56 (name "dummy")
57 (version "42")
58 (synopsis "dummy package")
59 (description "dummy package. Only used for testing purposes.")))
60EOF
61
62cat > "$tmpfile"<<EOF
63(use-modules (guix packages)
64 (foo))
65
66(format #t "~a\n" (package-version dummy))
67EOF
68
69test "`guix repl "$tmpfile" -L "$module_dir"`" = "42"
70
71cat > "$tmpfile"<<EOF
72(format #t "~a\n" (cdr (command-line)))
73EOF
74
75test "`guix repl -- "$tmpfile" -a b --input=foo.txt`" = "(-a b --input=foo.txt)"
76
77cat > "$tmpfile"<<EOF
78#!$(type -P env) -S guix repl --
79!#
80(format #t "~a\n" (cdr (command-line)))
81EOF
82chmod 755 $tmpfile
83
84test "`"$tmpfile" -a b --input=foo.txt`" = "(-a b --input=foo.txt)"