environment: Add --system.
[jackhill/guix/guix.git] / tests / guix-environment.sh
CommitLineData
cad25264
LC
1# GNU Guix --- Functional package management for GNU
2# Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
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 'guix environment'.
21#
22
23set -e
24
25guix environment --version
26
27tmpdir="t-guix-environment-$$"
28trap 'rm -r "$tmpdir"' EXIT
29
30mkdir "$tmpdir"
31
32# Check the environment variables for the bootstrap Guile.
33guix environment --ad-hoc guile-bootstrap --pure --search-paths > "$tmpdir/a"
34
35# $PATH must appear in the search paths, and nothing else.
36grep -E '^export PATH=.*guile-bootstrap-[0-9.]+/bin' "$tmpdir/a"
37test "`wc -l < "$tmpdir/a"`" = 1
38
39if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
40then
41 # Compute the build environment for the initial GNU Make.
42 guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \
43 --no-substitutes --search-paths --pure > "$tmpdir/a"
44
45 # Make sure the bootstrap binaries are all listed where they belong.
46 grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a"
47 grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a"
48 grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a"
49 grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a"
50
51 # 'make-boot0' itself must not be listed.
52 if grep "make-boot0" "$tmpdir/a"; then false; else true; fi
53
54 # Make sure that the shell spawned with '--exec' sees the same environment
55 # as returned by '--search-paths'.
56 guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \
57 --no-substitutes --pure \
58 --exec='echo $PATH $CPATH $LIBRARY_PATH' > "$tmpdir/b"
59 ( . "$tmpdir/a" ; echo $PATH $CPATH $LIBRARY_PATH ) > "$tmpdir/c"
60 cmp "$tmpdir/b" "$tmpdir/c"
6b6298ae
LC
61
62 rm "$tmpdir"/*
63
64 # Compute the build environment for the initial GNU Findutils.
65 guix environment -e '(@@ (gnu packages commencement) findutils-boot0)' \
66 --no-substitutes --search-paths --pure > "$tmpdir/a"
67
68 # Make sure the bootstrap binaries are all listed where they belong.
69 grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a"
70 grep -E '^export PATH=.*-make-boot0-[0-9.]+/bin' "$tmpdir/a"
71 grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a"
72 grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a"
73 grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a"
74
75 # The following test assumes 'make-boot0' has a "debug" output.
76 make_boot0_debug="`guix build -e '(@@ (gnu packages commencement) gnu-make-boot0)' | grep -e -debug`"
77 test "x$make_boot0_debug" != "x"
78
79 # Make sure the "debug" output is not listed.
80 if grep -E "$make_boot0_debug" "$tmpdir/a"; then false; else true; fi
cad25264 81fi