2021-10-01 13:19:54 +00:00
|
|
|
# GNU Guix --- Functional package management for GNU
|
2023-12-06 16:55:49 +00:00
|
|
|
# Copyright © 2021-2023 Ludovic Courtès <ludo@gnu.org>
|
2021-10-01 13:19:54 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2021-10-01 15:18:43 +00:00
|
|
|
configdir="t-guix-shell-config-$$"
|
2021-10-01 13:19:54 +00:00
|
|
|
tmpdir="t-guix-shell-$$"
|
2021-10-01 15:18:43 +00:00
|
|
|
trap 'rm -r "$tmpdir" "$configdir"' EXIT
|
|
|
|
mkdir "$tmpdir" "$configdir" "$configdir/guix"
|
|
|
|
|
|
|
|
XDG_CONFIG_HOME="$(realpath $configdir)"
|
|
|
|
export XDG_CONFIG_HOME
|
2021-10-01 13:19:54 +00:00
|
|
|
|
|
|
|
guix shell --bootstrap --pure guile-bootstrap -- guile --version
|
|
|
|
|
2022-10-25 20:32:01 +00:00
|
|
|
# '--symlink' can only be used with --container.
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 05:11:27 +00:00
|
|
|
guix shell --bootstrap guile-bootstrap -S /dummy=bin/guile && false
|
2022-10-25 20:32:01 +00:00
|
|
|
|
2021-10-01 13:19:54 +00:00
|
|
|
# '--ad-hoc' is a thing of the past.
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 05:11:27 +00:00
|
|
|
guix shell --ad-hoc guile-bootstrap && false
|
2021-10-01 13:19:54 +00:00
|
|
|
|
2022-02-17 15:06:39 +00:00
|
|
|
# Rejecting unsupported packages.
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 05:11:27 +00:00
|
|
|
guix shell -s armhf-linux intelmetool -n && false
|
2022-02-17 15:06:39 +00:00
|
|
|
|
2022-09-04 14:04:31 +00:00
|
|
|
# Test approximately that the child process does not inherit extra file
|
|
|
|
# descriptors. Ideally we'd check there's nothing more than 0, 1, and 2, but
|
|
|
|
# we cannot do that because (1) we might be inheriting additional FDs, for
|
|
|
|
# example due to <https://issues.guix.gnu.org/57567>, and (2) Bash itself
|
|
|
|
# opens a couple of extra FDs.
|
|
|
|
initial_fd_list="$(echo /proc/$$/fd/*)"
|
|
|
|
fd_list="$(guix shell --bootstrap guile-bootstrap -- \
|
2023-08-11 12:22:44 +00:00
|
|
|
bash -c 'echo /proc/$$/fd/*')"
|
2022-09-04 14:04:31 +00:00
|
|
|
test "$(echo $fd_list | wc -w)" -le "$(echo $initial_fd_list | wc -w)"
|
|
|
|
|
2021-10-01 15:18:43 +00:00
|
|
|
# Ignoring unauthorized files.
|
|
|
|
cat > "$tmpdir/guix.scm" <<EOF
|
|
|
|
This is a broken guix.scm file.
|
|
|
|
EOF
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 05:11:27 +00:00
|
|
|
(cd "$tmpdir"; SHELL="$(type -P true)" guix shell --bootstrap 2> "stderr") && false
|
2021-10-30 14:35:06 +00:00
|
|
|
grep "not authorized" "$tmpdir/stderr"
|
|
|
|
rm "$tmpdir/stderr"
|
2021-10-01 15:18:43 +00:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2021-12-10 11:26:29 +00:00
|
|
|
# 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"
|
|
|
|
|
2023-12-06 16:55:49 +00:00
|
|
|
# Make sure '--development' honors '--system'.
|
|
|
|
this_system="$(guile -c '(use-modules (guix utils))
|
|
|
|
(display (%current-system))')"
|
|
|
|
other_system="$(guile -c '(use-modules (guix utils))
|
|
|
|
(display (if (string=? "riscv64-linux" (%current-system))
|
|
|
|
"x86_64-linux"
|
|
|
|
"riscv64-linux"))')"
|
|
|
|
cat > "$tmpdir/some-package.scm" <<EOF
|
|
|
|
(use-modules (guix utils)
|
|
|
|
(guix packages)
|
|
|
|
(gnu packages base))
|
|
|
|
|
|
|
|
(define unsupported-dependency
|
|
|
|
(package
|
|
|
|
(inherit grep)
|
|
|
|
(name "unsupported-dependency")
|
|
|
|
(supported-systems '())))
|
|
|
|
|
|
|
|
(package
|
|
|
|
(inherit hello)
|
|
|
|
(name "phony-package")
|
|
|
|
(inputs
|
|
|
|
(if (string=? (%current-system) "$this_system")
|
|
|
|
(list unsupported-dependency)
|
|
|
|
'())))
|
|
|
|
EOF
|
|
|
|
|
|
|
|
guix shell -D -f "$tmpdir/some-package.scm" -n && false
|
|
|
|
guix shell -D -f "$tmpdir/some-package.scm" -n -s "$other_system"
|
|
|
|
|
|
|
|
|
2021-10-01 13:19:54 +00:00
|
|
|
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.
|
2021-11-18 21:59:40 +00:00
|
|
|
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"
|
2021-10-01 13:19:54 +00:00
|
|
|
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.
|
tests: Fix checks for expected failures.
Addresses <https://issues.guix.gnu.org/62406>.
With 'set -e', a return status inverted with '!' does not cause the shell to
exit immediately. Instead use '&& false' to indicate an expected failure.
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh,
tests/guix-environment-container.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-home.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh, tests/guix-refresh.sh, tests/guix-shell.sh,
tests/guix-style.sh, tests/guix-system.sh: Replace uses of '! ...' with
'... && false' or `test ! ...` as appropriate.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-20 05:11:27 +00:00
|
|
|
guix gc --references "$profile" | grep make-boot0 && false
|
2021-10-01 15:18:43 +00:00
|
|
|
|
|
|
|
# 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"
|
2021-10-01 13:19:54 +00:00
|
|
|
fi
|