Commit | Line | Data |
---|---|---|
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 | ||
23 | set -e | |
24 | ||
25 | guix environment --version | |
26 | ||
27 | tmpdir="t-guix-environment-$$" | |
28 | trap 'rm -r "$tmpdir"' EXIT | |
29 | ||
30 | mkdir "$tmpdir" | |
31 | ||
32 | # Check the environment variables for the bootstrap Guile. | |
33 | guix environment --ad-hoc guile-bootstrap --pure --search-paths > "$tmpdir/a" | |
417c39f1 | 34 | guix environment --ad-hoc guile-bootstrap:out --pure --search-paths > "$tmpdir/b" |
cad25264 LC |
35 | |
36 | # $PATH must appear in the search paths, and nothing else. | |
37 | grep -E '^export PATH=.*guile-bootstrap-[0-9.]+/bin' "$tmpdir/a" | |
38 | test "`wc -l < "$tmpdir/a"`" = 1 | |
39 | ||
417c39f1 LC |
40 | cmp "$tmpdir/a" "$tmpdir/b" |
41 | ||
4931dfcd | 42 | # Make sure the exit value is preserved. |
1de2fe95 DT |
43 | if guix environment --ad-hoc guile-bootstrap --pure -- guile -c '(exit 42)' |
44 | then | |
45 | false | |
46 | else | |
47 | test $? = 42 | |
48 | fi | |
49 | ||
50 | # Same as above, but with deprecated -E flag. | |
51 | if guix environment --ad-hoc guile-bootstrap --pure -E "guile -c '(exit 42)'" | |
4931dfcd LC |
52 | then |
53 | false | |
54 | else | |
55 | test $? = 42 | |
56 | fi | |
57 | ||
cad25264 LC |
58 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null |
59 | then | |
60 | # Compute the build environment for the initial GNU Make. | |
61 | guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ | |
62 | --no-substitutes --search-paths --pure > "$tmpdir/a" | |
63 | ||
64 | # Make sure the bootstrap binaries are all listed where they belong. | |
65 | grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a" | |
66 | grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a" | |
67 | grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a" | |
68 | grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a" | |
69 | ||
70 | # 'make-boot0' itself must not be listed. | |
71 | if grep "make-boot0" "$tmpdir/a"; then false; else true; fi | |
72 | ||
73 | # Make sure that the shell spawned with '--exec' sees the same environment | |
74 | # as returned by '--search-paths'. | |
75 | guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ | |
76 | --no-substitutes --pure \ | |
1de2fe95 | 77 | -- /bin/sh -c 'echo $PATH $CPATH $LIBRARY_PATH' > "$tmpdir/b" |
cad25264 LC |
78 | ( . "$tmpdir/a" ; echo $PATH $CPATH $LIBRARY_PATH ) > "$tmpdir/c" |
79 | cmp "$tmpdir/b" "$tmpdir/c" | |
6b6298ae LC |
80 | |
81 | rm "$tmpdir"/* | |
82 | ||
83 | # Compute the build environment for the initial GNU Findutils. | |
84 | guix environment -e '(@@ (gnu packages commencement) findutils-boot0)' \ | |
85 | --no-substitutes --search-paths --pure > "$tmpdir/a" | |
86 | ||
87 | # Make sure the bootstrap binaries are all listed where they belong. | |
88 | grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a" | |
89 | grep -E '^export PATH=.*-make-boot0-[0-9.]+/bin' "$tmpdir/a" | |
90 | grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a" | |
91 | grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a" | |
92 | grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a" | |
93 | ||
94 | # The following test assumes 'make-boot0' has a "debug" output. | |
95 | make_boot0_debug="`guix build -e '(@@ (gnu packages commencement) gnu-make-boot0)' | grep -e -debug`" | |
96 | test "x$make_boot0_debug" != "x" | |
97 | ||
98 | # Make sure the "debug" output is not listed. | |
99 | if grep -E "$make_boot0_debug" "$tmpdir/a"; then false; else true; fi | |
cc90fbbf DT |
100 | |
101 | # Compute the build environment for the initial GNU Make, but add in the | |
102 | # bootstrap Guile as an ad-hoc addition. | |
103 | guix environment -e '(@@ (gnu packages commencement) gnu-make-boot0)' \ | |
104 | --ad-hoc guile-bootstrap --no-substitutes --search-paths \ | |
105 | --pure > "$tmpdir/a" | |
106 | ||
107 | # Make sure the bootstrap binaries are all listed where they belong. | |
108 | cat $tmpdir/a | |
109 | grep -E '^export PATH=.*-bootstrap-binaries-0/bin' "$tmpdir/a" | |
110 | grep -E '^export PATH=.*-guile-bootstrap-2.0/bin' "$tmpdir/a" | |
111 | grep -E '^export CPATH=.*-gcc-bootstrap-0/include' "$tmpdir/a" | |
112 | grep -E '^export CPATH=.*-glibc-bootstrap-0/include' "$tmpdir/a" | |
113 | grep -E '^export LIBRARY_PATH=.*-glibc-bootstrap-0/lib' "$tmpdir/a" | |
cad25264 | 114 | fi |