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