gnu: Properly credit Konrad Hinsen.
[jackhill/guix/guix.git] / tests / guix-graph.sh
CommitLineData
88856916 1# GNU Guix --- Functional package management for GNU
88a96c56 2# Copyright © 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
ee9a735b 3# Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
88856916
LC
4#
5# This file is part of GNU Guix.
6#
7# GNU Guix is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or (at
10# your option) any later version.
11#
12# GNU Guix is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20#
21# Test the 'guix graph' command-line utility.
22#
23
ee9a735b
PN
24module_dir="t-guix-graph-$$"
25mkdir "$module_dir"
26trap "rm -rf $module_dir" EXIT
27
28tmpfile1="$module_dir/t-guix-graph1-$$"
29tmpfile2="$module_dir/t-guix-graph2-$$"
a773c314
LC
30trap 'rm -f "$tmpfile1" "$tmpfile2"' EXIT
31
ee9a735b
PN
32
33cat > "$module_dir/foo.scm"<<EOF
34(define-module (foo)
35 #:use-module (guix packages)
36 #:use-module (gnu packages base))
37
38(define-public dummy
39 (package (inherit hello)
40 (name "dummy")
41 (version "42")
42 (synopsis "dummy package")
43 (description "dummy package. Only used for testing purposes.")))
44EOF
45
46
88856916
LC
47guix graph --version
48
49for package in guile-bootstrap coreutils python
50do
38b92daa 51 for graph in package bag-emerged bag bag-with-origins
88856916
LC
52 do
53 guix graph -t "$graph" "$package" | grep "$package"
54 done
55done
56
57guix build guile-bootstrap
58guix graph -t references guile-bootstrap | grep guile-bootstrap
4c8f997a
LC
59
60guix graph -e '(@ (gnu packages bootstrap) %bootstrap-guile)' \
61 | grep guile-bootstrap
62
63if guix graph -e +; then false; else true; fi
a773c314
LC
64
65# Try passing store file names.
66
67guix graph -t references guile-bootstrap > "$tmpfile1"
68guix graph -t references `guix build guile-bootstrap` > "$tmpfile2"
69cmp "$tmpfile1" "$tmpfile2"
70
71# XXX: Filter the file names in the graph to work around the fact that we get
72# a mixture of relative and absolute file names.
73guix graph -t derivation coreutils > "$tmpfile1"
74guix graph -t derivation `guix build -d coreutils` > "$tmpfile2"
75cmp "$tmpfile1" "$tmpfile2"
3e962e59
LC
76
77# Try package transformation options.
78guix graph git | grep 'label = "openssl'
79guix graph git --with-input=openssl=libressl | grep 'label = "libressl'
80if guix graph git --with-input=openssl=libressl | grep 'label = "openssl'
81then false; else true; fi
ee9a735b
PN
82
83# Try --load-path
84guix graph -L $module_dir dummy | grep 'label = "dummy'
88a96c56
LC
85
86# Displaying shortest paths (or lack thereof).
87if guix graph --path emacs vim; then false; else true; fi
88
89path="\
90emacs
91gnutls
92guile
93libffi"
94test "`guix graph --path emacs libffi | cut -d '@' -f1`" = "$path"
95
96# At the derivation level, there's a direct path because libffi is propagated
97# via gtk+.
98test "`guix graph --path -t derivation emacs libffi | wc -l`" -ge 2