projects/guix·blob master · refs

78 lines · 2.5 KiB

1# GNU Guix --- Functional package management for GNU
2# Copyright © 2023 Antoine R. Dumont <[email protected]>
3# Copyright © 2023 Ludovic Courtès <[email protected]>
4#
5# This file is part of GNU Guix.
6#
7# GNU Guix is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or (at
10# your option) any later version.
11#
12# GNU Guix is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20#
21# Test the 'guix locate' command-line utility.
22#
23
24set -x
25
26RUN_EXPENSIVE_TESTS="${RUN_EXPENSIVE_TESTS:-false}"
27
28tmpdir="guix-index-$$"
29# In the following tests, we use two different databases, one for each
30# indexation method.
31tmpdb_manifests="$tmpdir/manifests/db.sqlite"
32tmpdb_store="$tmpdir/store/db.sqlite"
33trap 'rm -rf "$tmpdir" "$tmpdb_store" "$tmpdb_manifests"' EXIT
34
35guix locate --version
36
37# Preparing db locations for both indexation methods.
38mkdir -p "$(dirname "$tmpdb_manifests")" "$(dirname "$tmpdb_store")"
39
40cmd_manifests="guix locate --database=$tmpdb_manifests --method=manifests"
41cmd_store="guix locate --database=$tmpdb_store --method=store"
42
43# Lookup without any db should fail.
44guix locate --database="$tmpdb_manifests" guile && false
45guix locate --database="$tmpdb_store" guile && false
46
47# Lookup without anything in db should yield no results because the indexer
48# didn't stumble upon any profile.
49test -z "$(guix locate --database="$tmpdb_manifests" guile)"
50
51# Install a package.
52guix package --bootstrap --install guile-bootstrap \
53 --profile="$tmpdir/profile"
54
55# Look for 'guile'.
56$cmd_manifests --update
57$cmd_manifests guile | grep "$(guix build guile-bootstrap)/bin/guile"
58$cmd_manifests boot-9.scm | grep ^guile-bootstrap
59
60# Using a glob pattern.
61$cmd_manifests -g '*.scm' | grep "^guile-bootstrap.*boot-9"
62
63# Statistics.
64$cmd_manifests --stats
65
66if $RUN_EXPENSIVE_TESTS
67then
68 $cmd_store --update
69 $cmd_store guile
70 $cmd_store guile | grep "$(guix build guile-bootstrap)/bin/guile"
71 $cmd_store boot-9.scm | grep ^guile-bootstrap
72fi
73
74# The command below is an error: "no files to search for"...
75guix locate && false
76
77# ... but this one is fine.
78guix locate --clear