Commit | Line | Data |
---|---|---|
233e7676 | 1 | # GNU Guix --- Functional package management for GNU |
bacf980c | 2 | # Copyright © 2013, 2015, 2017, 2018, 2019 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 | 23 | guix gc --version |
fe8ff028 LC |
24 | |
25 | trap "rm -f guix-gc-root" EXIT | |
26 | rm -f guix-gc-root | |
27 | ||
ff23b47d LC |
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 | |
35 | ||
3a96d7c3 | 36 | # For some operations, passing extra arguments is an error. |
bacf980c | 37 | for option in "" "-C 500M" "--verify" "--optimize" "--list-roots" |
3a96d7c3 | 38 | do |
d8934360 | 39 | ! guix gc $option whatever |
3a96d7c3 LC |
40 | done |
41 | ||
3caab236 | 42 | # This should fail. |
d8934360 | 43 | ! guix gc --verify=foo |
3caab236 | 44 | |
ba8b732d LC |
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" | |
49 | ||
50 | guix gc --references "$drv" | grep -e -bash | |
51 | guix gc --references "$out" | |
52 | guix gc --references "$out/bin/guile" | |
53 | ||
d8934360 | 54 | ! guix gc --references /dev/null; |
ba8b732d | 55 | |
8980eea5 LC |
56 | # Check derivers. |
57 | guix gc --derivers "$out" | grep "$drv" | |
58 | ||
fe8ff028 | 59 | # Add then reclaim a .drv file. |
e49951eb | 60 | drv="`guix build idutils -d`" |
fe8ff028 LC |
61 | test -f "$drv" |
62 | ||
e49951eb MW |
63 | guix gc --list-dead | grep "$drv" |
64 | guix gc --delete "$drv" | |
fe8ff028 LC |
65 | ! test -f "$drv" |
66 | ||
67 | # Add a .drv, register it as a root. | |
e49951eb | 68 | drv="`guix build --root=guix-gc-root lsh -d`" |
fe8ff028 LC |
69 | test -f "$drv" && test -L guix-gc-root |
70 | ||
bacf980c LC |
71 | guix gc --list-roots | grep "$PWD/guix-gc-root" |
72 | ||
e49951eb | 73 | guix gc --list-live | grep "$drv" |
d8934360 | 74 | ! guix gc --delete "$drv"; |
fe8ff028 LC |
75 | |
76 | rm guix-gc-root | |
e49951eb MW |
77 | guix gc --list-dead | grep "$drv" |
78 | guix gc --delete "$drv" | |
fe8ff028 LC |
79 | ! test -f "$drv" |
80 | ||
81 | # Try a random collection. | |
e49951eb | 82 | guix gc -C 1KiB |
fe8ff028 LC |
83 | |
84 | # Check trivial error cases. | |
d8934360 | 85 | ! guix gc --delete /dev/null; |
cdb5b075 CS |
86 | |
87 | # Bug #19757 | |
88 | out="`guix build guile-bootstrap`" | |
89 | test -d "$out" | |
90 | ||
91 | guix gc --delete "$out" | |
92 | ||
93 | ! test -d "$out" | |
94 | ||
95 | out="`guix build guile-bootstrap`" | |
96 | test -d "$out" | |
97 | ||
98 | guix gc --delete "$out/" | |
99 | ||
100 | ! test -d "$out" | |
101 | ||
102 | out="`guix build guile-bootstrap`" | |
103 | test -d "$out" | |
104 | ||
105 | guix gc --delete "$out/bin/guile" |