epiphany w/ gtk4 and webkitgtk 2.38
[jackhill/guix/guix.git] / tests / guix-shell.sh
CommitLineData
80edb7df 1# GNU Guix --- Functional package management for GNU
5a573139 2# Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org>
80edb7df
LC
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#
20# Test the 'guix shell' alias.
21#
22
23guix shell --version
24
746584e0 25configdir="t-guix-shell-config-$$"
80edb7df 26tmpdir="t-guix-shell-$$"
746584e0
LC
27trap 'rm -r "$tmpdir" "$configdir"' EXIT
28mkdir "$tmpdir" "$configdir" "$configdir/guix"
29
30XDG_CONFIG_HOME="$(realpath $configdir)"
31export XDG_CONFIG_HOME
80edb7df
LC
32
33guix shell --bootstrap --pure guile-bootstrap -- guile --version
34
35# '--ad-hoc' is a thing of the past.
36! guix shell --ad-hoc guile-bootstrap
37
5a573139
LC
38# Rejecting unsupported packages.
39! guix shell -s armhf-linux intelmetool -n
40
7a2acbdc
LC
41# Test approximately that the child process does not inherit extra file
42# descriptors. Ideally we'd check there's nothing more than 0, 1, and 2, but
43# we cannot do that because (1) we might be inheriting additional FDs, for
44# example due to <https://issues.guix.gnu.org/57567>, and (2) Bash itself
45# opens a couple of extra FDs.
46initial_fd_list="$(echo /proc/$$/fd/*)"
47fd_list="$(guix shell --bootstrap guile-bootstrap -- \
48 "$SHELL" -c 'echo /proc/$$/fd/*')"
49test "$(echo $fd_list | wc -w)" -le "$(echo $initial_fd_list | wc -w)"
50
746584e0
LC
51# Ignoring unauthorized files.
52cat > "$tmpdir/guix.scm" <<EOF
53This is a broken guix.scm file.
54EOF
98173af5
LC
55! (cd "$tmpdir"; SHELL="$(type -P true)" guix shell --bootstrap 2> "stderr")
56grep "not authorized" "$tmpdir/stderr"
57rm "$tmpdir/stderr"
746584e0
LC
58
59# Authorize the directory.
60echo "$(realpath "$tmpdir")" > "$configdir/guix/shell-authorized-directories"
61
62# Ignoring 'manifest.scm' and 'guix.scm' in non-interactive use.
63(cd "$tmpdir"; guix shell --bootstrap -- true)
64mv "$tmpdir/guix.scm" "$tmpdir/manifest.scm"
65(cd "$tmpdir"; guix shell --bootstrap -- true)
66rm "$tmpdir/manifest.scm"
67
68# Honoring the local 'manifest.scm' file.
69cat > "$tmpdir/manifest.scm" <<EOF
70(specifications->manifest '("guile-bootstrap"))
71EOF
72cat > "$tmpdir/fake-shell.sh" <<EOF
73#!$SHELL
74# This fake shell allows us to test interactive use.
75exec echo "\$GUIX_ENVIRONMENT"
76EOF
77chmod +x "$tmpdir/fake-shell.sh"
78profile1="$(cd "$tmpdir"; SHELL="$(realpath fake-shell.sh)" guix shell --bootstrap)"
79profile2="$(guix shell --bootstrap guile-bootstrap -- "$SHELL" -c 'echo $GUIX_ENVIRONMENT')"
80test -n "$profile1"
81test "$profile1" = "$profile2"
82rm "$tmpdir/manifest.scm"
83
84# Do not read manifest when passed '-q'.
85echo "Broken manifest." > "$tmpdir/manifest.scm"
86(cd "$tmpdir"; SHELL="$(realpath fake-shell.sh)" guix shell --bootstrap -q)
87rm "$tmpdir/manifest.scm"
88
71977101
LC
89# Make sure '-D' affects only the immediately following '-f', and not packages
90# that appear later: <https://issues.guix.gnu.org/52093>.
91cat > "$tmpdir/empty-package.scm" <<EOF
92(use-modules (guix) (guix tests)
93 (guix build-system trivial))
94
95(dummy-package "empty-package"
96 (build-system trivial-build-system)) ;zero inputs
97EOF
98
99guix shell --bootstrap --pure -D -f "$tmpdir/empty-package.scm" \
100 guile-bootstrap -- guile --version
101rm "$tmpdir/empty-package.scm"
102
80edb7df
LC
103if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
104then
105 # Compute the build environment for the initial GNU Make.
106 guix shell --bootstrap --no-substitutes --search-paths --pure \
107 -D -e '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/a"
108
109 # Make sure bootstrap binaries are in the profile.
110 profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'`
111
112 # Make sure the bootstrap binaries are all listed where they belong.
3ad13562
LC
113 grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a"
114 grep -E "^export C_INCLUDE_PATH=\"$profile/include\"" "$tmpdir/a"
115 grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a"
80edb7df
LC
116 for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0
117 do
118 guix gc --references "$profile" | grep "$dep"
119 done
120
121 # 'make-boot0' itself must not be listed.
122 ! guix gc --references "$profile" | grep make-boot0
746584e0
LC
123
124 # Honoring the local 'guix.scm' file.
125 echo '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/guix.scm"
126 (cd "$tmpdir"; guix shell --bootstrap --search-paths --pure > "b")
127 cmp "$tmpdir/a" "$tmpdir/b"
128 rm "$tmpdir/guix.scm"
80edb7df 129fi