gnu: r-wgcna: Move to (gnu packages bioconductor).
[jackhill/guix/guix.git] / tests / guix-graph.sh
index 199258a..ccb4933 100644 (file)
@@ -1,5 +1,6 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 #
 # This file is part of GNU Guix.
 #
 # Test the 'guix graph' command-line utility.
 #
 
+module_dir="t-guix-graph-$$"
+mkdir "$module_dir"
+trap "rm -rf $module_dir" EXIT
+
+tmpfile1="$module_dir/t-guix-graph1-$$"
+tmpfile2="$module_dir/t-guix-graph2-$$"
+trap 'rm -f "$tmpfile1" "$tmpfile2"' EXIT
+
+
+cat > "$module_dir/foo.scm"<<EOF
+(define-module (foo)
+  #:use-module (guix packages)
+  #:use-module (gnu packages base))
+
+(define-public dummy
+  (package (inherit hello)
+    (name "dummy")
+    (version "42")
+    (synopsis "dummy package")
+    (description "dummy package. Only used for testing purposes.")))
+EOF
+
+
 guix graph --version
 
 for package in guile-bootstrap coreutils python
 do
-    for graph in package bag-emerged bag
+    for graph in package bag-emerged bag bag-with-origins
     do
        guix graph -t "$graph" "$package" | grep "$package"
     done
@@ -32,3 +56,43 @@ done
 
 guix build guile-bootstrap
 guix graph -t references guile-bootstrap | grep guile-bootstrap
+
+guix graph -e '(@ (gnu packages bootstrap) %bootstrap-guile)' \
+    | grep guile-bootstrap
+
+if guix graph -e +; then false; else true; fi
+
+# Try passing store file names.
+
+guix graph -t references guile-bootstrap > "$tmpfile1"
+guix graph -t references `guix build guile-bootstrap` > "$tmpfile2"
+cmp "$tmpfile1" "$tmpfile2"
+
+# XXX: Filter the file names in the graph to work around the fact that we get
+# a mixture of relative and absolute file names.
+guix graph -t derivation coreutils > "$tmpfile1"
+guix graph -t derivation `guix build -d coreutils` > "$tmpfile2"
+cmp "$tmpfile1" "$tmpfile2"
+
+# Try package transformation options.
+guix graph git | grep 'label = "openssl'
+guix graph git --with-input=openssl=libressl | grep 'label = "libressl'
+if guix graph git --with-input=openssl=libressl | grep 'label = "openssl'
+then false; else true; fi
+
+# Try --load-path
+guix graph -L $module_dir dummy | grep 'label = "dummy'
+
+# Displaying shortest paths (or lack thereof).
+if guix graph --path emacs vim; then false; else true; fi
+
+path="\
+emacs
+gnutls
+guile
+libffi"
+test "`guix graph --path emacs libffi | cut -d '@' -f1`" = "$path"
+
+# At the derivation level, there's a direct path because libffi is propagated
+# via gtk+.
+test "`guix graph --path -t derivation emacs libffi | wc -l`" -ge 2