gnu: guile: Update to 2.2.2.
[jackhill/guix/guix.git] / tests / guix-build.sh
CommitLineData
233e7676 1# GNU Guix --- Functional package management for GNU
f6396d86 2# Copyright © 2012, 2013, 2014, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
97298ffa 3#
233e7676 4# This file is part of GNU Guix.
97298ffa 5#
233e7676 6# GNU Guix is free software; you can redistribute it and/or modify it
97298ffa
LC
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#
233e7676 11# GNU Guix is distributed in the hope that it will be useful, but
97298ffa
LC
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
233e7676 17# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
97298ffa
LC
18
19#
e49951eb 20# Test the `guix build' command-line utility.
97298ffa
LC
21#
22
e49951eb 23guix build --version
97298ffa
LC
24
25# Should fail.
e49951eb 26if guix build -e +;
912209ee
LC
27then false; else true; fi
28
d223ac4a
LC
29# Source-less packages are accepted; they just return nothing.
30guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S
31test "`guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S`" = ""
97298ffa
LC
32
33# Should pass.
af9142dc 34guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' | \
97298ffa 35 grep -e '-guile-'
e49951eb 36guix build hello -d | \
97298ffa
LC
37 grep -e '-hello-[0-9\.]\+\.drv$'
38
2cdfe13d
EB
39# Check --sources option with its arguments
40module_dir="t-guix-build-$$"
41mkdir "$module_dir"
42trap "rm -rf $module_dir" EXIT
43
44cat > "$module_dir/foo.scm"<<EOF
45(define-module (foo)
94d609ab 46 #:use-module (guix tests)
2cdfe13d
EB
47 #:use-module (guix packages)
48 #:use-module (guix download)
49 #:use-module (guix build-system trivial))
50
51(define-public foo
52 (package
53 (name "foo")
54 (version "42")
55 (source (origin
56 (method url-fetch)
57 (uri "http://www.example.com/foo.tar.gz")
58 (sha256
59 (base32
60 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))))
61 (build-system trivial-build-system)
62 (inputs
63 (quasiquote (("bar" ,bar))))
64 (home-page "www.example.com")
65 (synopsis "Dummy package")
66 (description "foo is a dummy package for testing.")
67 (license #f)))
68
69(define-public bar
70 (package
71 (name "bar")
72 (version "9001")
73 (source (origin
74 (method url-fetch)
75 (uri "http://www.example.com/bar.tar.gz")
76 (sha256
77 (base32
78 "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"))))
79 (build-system trivial-build-system)
80 (inputs
81 (quasiquote
82 (("data" ,(origin
83 (method url-fetch)
84 (uri "http://www.example.com/bar.dat")
85 (sha256
86 (base32
87 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")))))))
88 (home-page "www.example.com")
89 (synopsis "Dummy package")
90 (description "bar is a dummy package for testing.")
91 (license #f)))
94d609ab
LC
92
93(define-public baz
94 (dummy-package "baz" (replacement foo)))
95
01afdab8
LC
96(define-public superseded
97 (deprecated-package "superseded" bar))
98
2cdfe13d
EB
99EOF
100
101GUIX_PACKAGE_PATH="$module_dir"
102export GUIX_PACKAGE_PATH
103
104# foo.tar.gz
105guix build -d -S foo
106guix build -d -S foo | grep -e 'foo\.tar\.gz'
107
94d609ab
LC
108# 'baz' has a replacement so we should be getting the replacement's source.
109(unset GUIX_BUILD_OPTIONS;
110 test "`guix build -d -S baz`" = "`guix build -d -S foo`")
111
2cdfe13d
EB
112guix build -d --sources=package foo
113guix build -d --sources=package foo | grep -e 'foo\.tar\.gz'
114
115# bar.tar.gz and bar.dat
116guix build -d --sources bar
117test `guix build -d --sources bar \
118 | grep -e 'bar\.tar\.gz' -e 'bar\.dat' \
119 | wc -l` -eq 2
120
121# bar.tar.gz and bar.dat
122guix build -d --sources=all bar
123test `guix build -d --sources bar \
124 | grep -e 'bar\.tar\.gz' -e 'bar\.dat' \
125 | wc -l` -eq 2
126
127# Should include foo.tar.gz, bar.tar.gz, and bar.dat
128guix build -d --sources=transitive foo
129test `guix build -d --sources=transitive foo \
130 | grep -e 'foo\.tar\.gz' -e 'bar\.tar\.gz' -e 'bar\.dat' \
131 | wc -l` -eq 3
132
bf421152 133# Should all return valid log files.
af9142dc
LC
134drv="`guix build -d -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
135out="`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
bf421152
LC
136log="`guix build --log-file $drv`"
137echo "$log" | grep log/.*guile.*drv
138test -f "$log"
af9142dc 139test "`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' --log-file`" \
bf421152
LC
140 = "$log"
141test "`guix build --log-file guile-bootstrap`" = "$log"
142test "`guix build --log-file $out`" = "$log"
143
97298ffa 144# Should fail because the name/version combination could not be found.
e49951eb 145if guix build hello-0.0.1 -n; then false; else true; fi
97298ffa
LC
146
147# Keep a symlink to the result, registered as a root.
148result="t-result-$$"
e49951eb 149guix build -r "$result" \
af9142dc 150 -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
97298ffa
LC
151test -x "$result/bin/guile"
152
153# Should fail, because $result already exists.
af9142dc 154if guix build -r "$result" -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
97298ffa
LC
155then false; else true; fi
156
157rm -f "$result"
5401dd75 158
e55ec43d
LC
159# Cross building.
160guix build coreutils --target=mips64el-linux-gnu --dry-run --no-substitutes
161
47c0f92c 162# Replacements.
f6396d86 163drv1=`guix build guix --with-input=guile@2.0=guile@2.2 -d`
47c0f92c
LC
164drv2=`guix build guix -d`
165test "$drv1" != "$drv2"
166
167drv1=`guix build guile -d`
168drv2=`guix build guile --with-input=gimp=ruby -d`
169test "$drv1" = "$drv2"
170
171if guix build guile --with-input=libunistring=something-really-silly
172then false; else true; fi
173
01afdab8
LC
174# Deprecated/superseded packages.
175test "`guix build superseded -d`" = "`guix build bar -d`"
176
5401dd75 177# Parsing package names and versions.
e49951eb 178guix build -n time # PASS
1b846da8 179guix build -n time@1.7 # PASS, version found
95cd4971 180guix build -n time-1.7 # PASS, deprecated version syntax
1b846da8 181if guix build -n time@3.2; # FAIL, version not found
5401dd75 182then false; else true; fi
e49951eb 183if guix build -n something-that-will-never-exist; # FAIL
5401dd75 184then false; else true; fi
ac5de156
LC
185
186# Invoking a monadic procedure.
187guix build -e "(begin
ada3df03 188 (use-modules (guix gexp))
ac5de156 189 (lambda ()
ada3df03
LC
190 (gexp->derivation \"test\"
191 (gexp (mkdir (ungexp output))))))" \
ac5de156 192 --dry-run
56b82106
LC
193
194# Running a gexp.
195guix build -e '#~(mkdir #$output)' -d
196guix build -e '#~(mkdir #$output)' -d | grep 'gexp\.drv'
16eb115e 197
34a1783f
DT
198# Building from a package file.
199cat > "$module_dir/package.scm"<<EOF
200(use-modules (gnu))
201(use-package-modules bootstrap)
202
203%bootstrap-guile
204EOF
205guix build --file="$module_dir/package.scm"
206
207# Building from a monadic procedure file.
208cat > "$module_dir/proc.scm"<<EOF
209(use-modules (guix gexp))
210(lambda ()
211 (gexp->derivation "test"
212 (gexp (mkdir (ungexp output)))))
213EOF
214guix build --file="$module_dir/proc.scm" --dry-run
215
216# Building from a gexp file.
217cat > "$module_dir/gexp.scm"<<EOF
218(use-modules (guix gexp))
219
220(gexp (mkdir (ungexp output)))
221EOF
222guix build --file="$module_dir/gexp.scm" -d
223guix build --file="$module_dir/gexp.scm" -d | grep 'gexp\.drv'
224
16eb115e 225# Using 'GUIX_BUILD_OPTIONS'.
442a6ff5 226GUIX_BUILD_OPTIONS="--dry-run --no-grafts"
16eb115e
DP
227export GUIX_BUILD_OPTIONS
228
229guix build emacs
230
231GUIX_BUILD_OPTIONS="--something-completely-crazy"
232if guix build emacs;
233then false; else true; fi