diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-01-25 22:07:13 -0500 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-01-25 22:07:13 -0500 |
commit | 1a5302435ff0d2822b823f5a6fe01faa7a85c629 (patch) | |
tree | ac7810c88b560532f22d2bab2e59609cd7305c21 /tests/guix-shell.sh | |
parent | 3ff2ac4980dacf10087e4b42bd9fbc490591900c (diff) | |
parent | 070b8a893febd6e7d8b2b7c8c4dcebacf7845aa9 (diff) |
Merge branch 'master' into staging.
With "conflicts" solved (all in favor of master except git) in:
gnu/local.mk
gnu/packages/databases.scm
gnu/packages/glib.scm
gnu/packages/gnome.scm
gnu/packages/gnupg.scm
gnu/packages/gnuzilla.scm
gnu/packages/graphics.scm
gnu/packages/gstreamer.scm
gnu/packages/gtk.scm
gnu/packages/linux.scm
gnu/packages/machine-learning.scm
gnu/packages/networking.scm
gnu/packages/polkit.scm
gnu/packages/pulseaudio.scm
gnu/packages/rpc.scm
gnu/packages/rust.scm
gnu/packages/version-control.scm
gnu/packages/w3m.scm
Diffstat (limited to 'tests/guix-shell.sh')
-rw-r--r-- | tests/guix-shell.sh | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh new file mode 100644 index 0000000000..23ff1c5bcf --- /dev/null +++ b/tests/guix-shell.sh @@ -0,0 +1,116 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2021 Ludovic Courtès <ludo@gnu.org> +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +# +# Test the 'guix shell' alias. +# + +guix shell --version + +configdir="t-guix-shell-config-$$" +tmpdir="t-guix-shell-$$" +trap 'rm -r "$tmpdir" "$configdir"' EXIT +mkdir "$tmpdir" "$configdir" "$configdir/guix" + +XDG_CONFIG_HOME="$(realpath $configdir)" +export XDG_CONFIG_HOME + +guix shell --bootstrap --pure guile-bootstrap -- guile --version + +# '--ad-hoc' is a thing of the past. +! guix shell --ad-hoc guile-bootstrap + +# Ignoring unauthorized files. +cat > "$tmpdir/guix.scm" <<EOF +This is a broken guix.scm file. +EOF +! (cd "$tmpdir"; SHELL="$(type -P true)" guix shell --bootstrap 2> "stderr") +grep "not authorized" "$tmpdir/stderr" +rm "$tmpdir/stderr" + +# Authorize the directory. +echo "$(realpath "$tmpdir")" > "$configdir/guix/shell-authorized-directories" + +# Ignoring 'manifest.scm' and 'guix.scm' in non-interactive use. +(cd "$tmpdir"; guix shell --bootstrap -- true) +mv "$tmpdir/guix.scm" "$tmpdir/manifest.scm" +(cd "$tmpdir"; guix shell --bootstrap -- true) +rm "$tmpdir/manifest.scm" + +# Honoring the local 'manifest.scm' file. +cat > "$tmpdir/manifest.scm" <<EOF +(specifications->manifest '("guile-bootstrap")) +EOF +cat > "$tmpdir/fake-shell.sh" <<EOF +#!$SHELL +# This fake shell allows us to test interactive use. +exec echo "\$GUIX_ENVIRONMENT" +EOF +chmod +x "$tmpdir/fake-shell.sh" +profile1="$(cd "$tmpdir"; SHELL="$(realpath fake-shell.sh)" guix shell --bootstrap)" +profile2="$(guix shell --bootstrap guile-bootstrap -- "$SHELL" -c 'echo $GUIX_ENVIRONMENT')" +test -n "$profile1" +test "$profile1" = "$profile2" +rm "$tmpdir/manifest.scm" + +# Do not read manifest when passed '-q'. +echo "Broken manifest." > "$tmpdir/manifest.scm" +(cd "$tmpdir"; SHELL="$(realpath fake-shell.sh)" guix shell --bootstrap -q) +rm "$tmpdir/manifest.scm" + +# Make sure '-D' affects only the immediately following '-f', and not packages +# that appear later: <https://issues.guix.gnu.org/52093>. +cat > "$tmpdir/empty-package.scm" <<EOF +(use-modules (guix) (guix tests) + (guix build-system trivial)) + +(dummy-package "empty-package" + (build-system trivial-build-system)) ;zero inputs +EOF + +guix shell --bootstrap --pure -D -f "$tmpdir/empty-package.scm" \ + guile-bootstrap -- guile --version +rm "$tmpdir/empty-package.scm" + +if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null +then + # Compute the build environment for the initial GNU Make. + guix shell --bootstrap --no-substitutes --search-paths --pure \ + -D -e '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/a" + + # Make sure bootstrap binaries are in the profile. + profile=`grep "^export PATH" "$tmpdir/a" | sed -r 's|^.*="(.*)/bin"|\1|'` + + # Make sure the bootstrap binaries are all listed where they belong. + grep -E "^export PATH=\"$profile/bin\"" "$tmpdir/a" + grep -E "^export C_INCLUDE_PATH=\"$profile/include\"" "$tmpdir/a" + grep -E "^export LIBRARY_PATH=\"$profile/lib\"" "$tmpdir/a" + for dep in bootstrap-binaries-0 gcc-bootstrap-0 glibc-bootstrap-0 + do + guix gc --references "$profile" | grep "$dep" + done + + # 'make-boot0' itself must not be listed. + ! guix gc --references "$profile" | grep make-boot0 + + # Honoring the local 'guix.scm' file. + echo '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/guix.scm" + (cd "$tmpdir"; guix shell --bootstrap --search-paths --pure > "b") + cmp "$tmpdir/a" "$tmpdir/b" + rm "$tmpdir/guix.scm" +fi |