guix-graph.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # GNU Guix --- Functional package management for GNU
  2. # Copyright © 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  3. # Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
  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 graph' command-line utility.
  21. #
  22. module_dir="t-guix-graph-$$"
  23. mkdir "$module_dir"
  24. trap "rm -rf $module_dir" EXIT
  25. tmpfile1="$module_dir/t-guix-graph1-$$"
  26. tmpfile2="$module_dir/t-guix-graph2-$$"
  27. trap 'rm -f "$tmpfile1" "$tmpfile2"' EXIT
  28. cat > "$module_dir/foo.scm"<<EOF
  29. (define-module (foo)
  30. #:use-module (guix packages)
  31. #:use-module (gnu packages base))
  32. (define-public dummy
  33. (package (inherit hello)
  34. (name "dummy")
  35. (version "42")
  36. (synopsis "dummy package")
  37. (description "dummy package. Only used for testing purposes.")))
  38. EOF
  39. guix graph --version
  40. for package in guile-bootstrap coreutils python
  41. do
  42. for graph in package bag-emerged bag bag-with-origins
  43. do
  44. guix graph -t "$graph" "$package" | grep "$package"
  45. done
  46. done
  47. guix build guile-bootstrap
  48. guix graph -t references guile-bootstrap | grep guile-bootstrap
  49. guix graph -e '(@ (gnu packages bootstrap) %bootstrap-guile)' \
  50. | grep guile-bootstrap
  51. ! guix graph -e +
  52. # Try passing store file names.
  53. guix graph -t references guile-bootstrap > "$tmpfile1"
  54. guix graph -t references `guix build guile-bootstrap` > "$tmpfile2"
  55. cmp "$tmpfile1" "$tmpfile2"
  56. # XXX: Filter the file names in the graph to work around the fact that we get
  57. # a mixture of relative and absolute file names.
  58. guix graph -t derivation coreutils > "$tmpfile1"
  59. guix graph -t derivation `guix build -d coreutils` > "$tmpfile2"
  60. cmp "$tmpfile1" "$tmpfile2"
  61. # Try package transformation options.
  62. guix graph git | grep 'label = "openssl'
  63. guix graph git --with-input=openssl=libressl | grep 'label = "libressl'
  64. ! guix graph git --with-input=openssl=libressl | grep 'label = "openssl'
  65. # Try --load-path
  66. guix graph -L $module_dir dummy | grep 'label = "dummy'
  67. # Displaying shortest paths (or lack thereof).
  68. ! guix graph --path emacs vim
  69. path="\
  70. emacs
  71. gnutls
  72. guile
  73. libffi"
  74. test "`guix graph --path emacs libffi | cut -d '@' -f1`" = "$path"
  75. # At the derivation level, there's a direct path because libffi is propagated
  76. # via gtk+.
  77. test "`guix graph --path -t derivation emacs libffi | wc -l`" -ge 2