projects/guix·blob master · refs

105 lines · 2.7 KiB

1# GNU Guix --- Functional package management for GNU
2# Copyright © 2013, 2015, 2017, 2018, 2019 Ludovic Courtès <[email protected]>
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 the `guix gc' command-line utility.
21#
22
23guix gc --version
24
25trap "rm -f guix-gc-root" EXIT
26rm -f guix-gc-root
27
28# Below we are using 'drv' and 'out' to contain store file names. If 'drv'
29# and 'out' are environment variables, 'list-runtime-roots' will "see" them
30# and thus prevent $drv and $out from being garbage-collected. Using 'unset'
31# allows us to make sure these are truly local shell variables and not
32# environments variables.
33unset drv
34unset out
35
36# For some operations, passing extra arguments is an error.
37for option in "" "-C 500M" "--verify" "--optimize" "--list-roots"
38do
39 guix gc $option whatever && false
40done
41
42# This should fail.
43guix gc --verify=foo && false
44
45# Check the references of a .drv.
46drv="`guix build guile-bootstrap -d`"
47out="`guix build guile-bootstrap`"
48test -f "$drv" && test -d "$out"
49
50guix gc --references "$drv" | grep -e -bash
51guix gc --references "$out"
52guix gc --references "$out/bin/guile"
53
54guix gc --references /dev/null && false
55
56# Check derivers.
57guix gc --derivers "$out" | grep "$drv"
58
59# Add then reclaim a .drv file.
60drv="`guix build idutils -d`"
61test -f "$drv"
62
63guix gc --list-dead | grep "$drv"
64guix gc --delete "$drv"
65test ! -f "$drv"
66
67# Add a .drv, register it as a root.
68drv="`guix build --root=guix-gc-root hello -d`"
69test -f "$drv" && test -L guix-gc-root
70
71guix gc --list-roots | grep "$PWD/guix-gc-root"
72
73guix gc --list-live | grep "$drv"
74guix gc --delete "$drv" && false
75
76rm guix-gc-root
77guix gc --list-dead | grep "$drv"
78guix gc --delete "$drv"
79test ! -f "$drv"
80
81# Try a random collection.
82guix gc -C 1KiB
83
84# Check trivial error cases.
85guix gc --delete /dev/null && false
86
87# Bug #19757
88out="`guix build guile-bootstrap`"
89test -d "$out"
90
91guix gc --delete "$out"
92
93test ! -d "$out"
94
95out="`guix build guile-bootstrap`"
96test -d "$out"
97
98guix gc --delete "$out/"
99
100test ! -d "$out"
101
102out="`guix build guile-bootstrap`"
103test -d "$out"
104
105guix gc --delete "$out/bin/guile"