guix-locate.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # GNU Guix --- Functional package management for GNU
  2. # Copyright © 2023 Antoine R. Dumont <antoine.romain.dumont@gmail.com>
  3. # Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
  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. # Test the 'guix locate' command-line utility.
  21. #
  22. set -x
  23. RUN_EXPENSIVE_TESTS="${RUN_EXPENSIVE_TESTS:-false}"
  24. tmpdir="guix-index-$$"
  25. # In the following tests, we use two different databases, one for each
  26. # indexation method.
  27. tmpdb_manifests="$tmpdir/manifests/db.sqlite"
  28. tmpdb_store="$tmpdir/store/db.sqlite"
  29. trap 'rm -rf "$tmpdir" "$tmpdb_store" "$tmpdb_manifests"' EXIT
  30. guix locate --version
  31. # Preparing db locations for both indexation methods.
  32. mkdir -p "$(dirname "$tmpdb_manifests")" "$(dirname "$tmpdb_store")"
  33. cmd_manifests="guix locate --database=$tmpdb_manifests --method=manifests"
  34. cmd_store="guix locate --database=$tmpdb_store --method=store"
  35. # Lookup without any db should fail.
  36. guix locate --database="$tmpdb_manifests" guile && false
  37. guix locate --database="$tmpdb_store" guile && false
  38. # Lookup without anything in db should yield no results because the indexer
  39. # didn't stumble upon any profile.
  40. test -z "$(guix locate --database="$tmpdb_manifests" guile)"
  41. # Install a package.
  42. guix package --bootstrap --install guile-bootstrap \
  43. --profile="$tmpdir/profile"
  44. # Look for 'guile'.
  45. $cmd_manifests --update
  46. $cmd_manifests guile | grep "$(guix build guile-bootstrap)/bin/guile"
  47. $cmd_manifests boot-9.scm | grep ^guile-bootstrap
  48. # Using a glob pattern.
  49. $cmd_manifests -g '*.scm' | grep "^guile-bootstrap.*boot-9"
  50. # Statistics.
  51. $cmd_manifests --stats
  52. if $RUN_EXPENSIVE_TESTS
  53. then
  54. $cmd_store --update
  55. $cmd_store guile
  56. $cmd_store guile | grep "$(guix build guile-bootstrap)/bin/guile"
  57. $cmd_store boot-9.scm | grep ^guile-bootstrap
  58. fi