doc: Create "Version Control Services" section.
[guix.git] / tests / guix-gc.sh
blob57c5e7dd616bf142abe571526eba88c7dfc8bc0b
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2013, 2015, 2017 Ludovic Courtès <ludo@gnu.org>
4 # This file is part of GNU Guix.
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.
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.
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/>.
20 # Test the `guix gc' command-line utility.
23 guix gc --version
25 trap "rm -f guix-gc-root" EXIT
26 rm -f guix-gc-root
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.
33 unset drv
34 unset out
36 # For some operations, passing extra arguments is an error.
37 for option in "" "-C 500M" "--verify" "--optimize"
39 if guix gc $option whatever; then false; else true; fi
40 done
42 # Check the references of a .drv.
43 drv="`guix build guile-bootstrap -d`"
44 out="`guix build guile-bootstrap`"
45 test -f "$drv" && test -d "$out"
47 guix gc --references "$drv" | grep -e -bash
48 guix gc --references "$out"
49 guix gc --references "$out/bin/guile"
51 if guix gc --references /dev/null;
52 then false; else true; fi
54 # Add then reclaim a .drv file.
55 drv="`guix build idutils -d`"
56 test -f "$drv"
58 guix gc --list-dead | grep "$drv"
59 guix gc --delete "$drv"
60 ! test -f "$drv"
62 # Add a .drv, register it as a root.
63 drv="`guix build --root=guix-gc-root lsh -d`"
64 test -f "$drv" && test -L guix-gc-root
66 guix gc --list-live | grep "$drv"
67 if guix gc --delete "$drv";
68 then false; else true; fi
70 rm guix-gc-root
71 guix gc --list-dead | grep "$drv"
72 guix gc --delete "$drv"
73 ! test -f "$drv"
75 # Try a random collection.
76 guix gc -C 1KiB
78 # Check trivial error cases.
79 if guix gc --delete /dev/null;
80 then false; else true; fi
82 # Bug #19757
83 out="`guix build guile-bootstrap`"
84 test -d "$out"
86 guix gc --delete "$out"
88 ! test -d "$out"
90 out="`guix build guile-bootstrap`"
91 test -d "$out"
93 guix gc --delete "$out/"
95 ! test -d "$out"
97 out="`guix build guile-bootstrap`"
98 test -d "$out"
100 guix gc --delete "$out/bin/guile"