gnu: lxqt-policykit: Update to 0.14.1.
[guix.git] / tests / guix-gc.sh
blobef2d9543b72a189527f2029b292f2d4860956f21
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2013, 2015, 2017, 2018 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 # This should fail.
43 if guix gc --verify=foo; then false; else true; fi
45 # Check the references of a .drv.
46 drv="`guix build guile-bootstrap -d`"
47 out="`guix build guile-bootstrap`"
48 test -f "$drv" && test -d "$out"
50 guix gc --references "$drv" | grep -e -bash
51 guix gc --references "$out"
52 guix gc --references "$out/bin/guile"
54 if guix gc --references /dev/null;
55 then false; else true; fi
57 # Check derivers.
58 guix gc --derivers "$out" | grep "$drv"
60 # Add then reclaim a .drv file.
61 drv="`guix build idutils -d`"
62 test -f "$drv"
64 guix gc --list-dead | grep "$drv"
65 guix gc --delete "$drv"
66 ! test -f "$drv"
68 # Add a .drv, register it as a root.
69 drv="`guix build --root=guix-gc-root lsh -d`"
70 test -f "$drv" && test -L guix-gc-root
72 guix gc --list-live | grep "$drv"
73 if guix gc --delete "$drv";
74 then false; else true; fi
76 rm guix-gc-root
77 guix gc --list-dead | grep "$drv"
78 guix gc --delete "$drv"
79 ! test -f "$drv"
81 # Try a random collection.
82 guix gc -C 1KiB
84 # Check trivial error cases.
85 if guix gc --delete /dev/null;
86 then false; else true; fi
88 # Bug #19757
89 out="`guix build guile-bootstrap`"
90 test -d "$out"
92 guix gc --delete "$out"
94 ! test -d "$out"
96 out="`guix build guile-bootstrap`"
97 test -d "$out"
99 guix gc --delete "$out/"
101 ! test -d "$out"
103 out="`guix build guile-bootstrap`"
104 test -d "$out"
106 guix gc --delete "$out/bin/guile"