graft: Correctly replace references near the end of the scan buffer.
[jackhill/guix/guix.git] / tests / guix-gc.sh
CommitLineData
233e7676 1# GNU Guix --- Functional package management for GNU
3a96d7c3 2# Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org>
fe8ff028 3#
233e7676 4# This file is part of GNU Guix.
fe8ff028 5#
233e7676 6# GNU Guix is free software; you can redistribute it and/or modify it
fe8ff028
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
fe8ff028
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/>.
fe8ff028
LC
18
19#
e49951eb 20# Test the `guix gc' command-line utility.
fe8ff028
LC
21#
22
e49951eb 23guix gc --version
fe8ff028
LC
24
25trap "rm -f guix-gc-root" EXIT
26rm -f guix-gc-root
27
3a96d7c3
LC
28# For some operations, passing extra arguments is an error.
29for option in "" "-C 500M" "--verify" "--optimize"
30do
31 if guix gc $option whatever; then false; else true; fi
32done
33
ba8b732d
LC
34# Check the references of a .drv.
35drv="`guix build guile-bootstrap -d`"
36out="`guix build guile-bootstrap`"
37test -f "$drv" && test -d "$out"
38
39guix gc --references "$drv" | grep -e -bash
40guix gc --references "$out"
41guix gc --references "$out/bin/guile"
42
43if guix gc --references /dev/null;
44then false; else true; fi
45
fe8ff028 46# Add then reclaim a .drv file.
e49951eb 47drv="`guix build idutils -d`"
fe8ff028
LC
48test -f "$drv"
49
e49951eb
MW
50guix gc --list-dead | grep "$drv"
51guix gc --delete "$drv"
fe8ff028
LC
52! test -f "$drv"
53
54# Add a .drv, register it as a root.
e49951eb 55drv="`guix build --root=guix-gc-root lsh -d`"
fe8ff028
LC
56test -f "$drv" && test -L guix-gc-root
57
e49951eb
MW
58guix gc --list-live | grep "$drv"
59if guix gc --delete "$drv";
fe8ff028
LC
60then false; else true; fi
61
62rm guix-gc-root
e49951eb
MW
63guix gc --list-dead | grep "$drv"
64guix gc --delete "$drv"
fe8ff028
LC
65! test -f "$drv"
66
67# Try a random collection.
e49951eb 68guix gc -C 1KiB
fe8ff028
LC
69
70# Check trivial error cases.
e49951eb 71if guix gc --delete /dev/null;
fe8ff028 72then false; else true; fi
cdb5b075
CS
73
74# Bug #19757
75out="`guix build guile-bootstrap`"
76test -d "$out"
77
78guix gc --delete "$out"
79
80! test -d "$out"
81
82out="`guix build guile-bootstrap`"
83test -d "$out"
84
85guix gc --delete "$out/"
86
87! test -d "$out"
88
89out="`guix build guile-bootstrap`"
90test -d "$out"
91
92guix gc --delete "$out/bin/guile"