import: github: Improve readability.
[jackhill/guix/guix.git] / tests / guix-build.sh
index 5821e50..7842ce8 100644 (file)
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2012, 2013, 2014, 2016 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012, 2013, 2014, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of GNU Guix.
 #
@@ -26,9 +26,9 @@ guix build --version
 if guix build -e +;
 then false; else true; fi
 
-# Should fail because this is a source-less package.
-if guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S
-then false; else true; fi
+# Source-less packages are accepted; they just return nothing.
+guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S
+test "`guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S`" = ""
 
 # Should pass.
 guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' |       \
@@ -36,6 +36,14 @@ guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' |     \
 guix build hello -d |                          \
     grep -e '-hello-[0-9\.]\+\.drv$'
 
+# Passing a URI.
+GUIX_DAEMON_SOCKET="file://$NIX_STATE_DIR/daemon-socket/socket"        \
+guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
+
+( if GUIX_DAEMON_SOCKET="weird://uri"                                  \
+     guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)';   \
+  then exit 1; fi )
+
 # Check --sources option with its arguments
 module_dir="t-guix-build-$$"
 mkdir "$module_dir"
@@ -43,6 +51,7 @@ trap "rm -rf $module_dir" EXIT
 
 cat > "$module_dir/foo.scm"<<EOF
 (define-module (foo)
+  #:use-module (guix tests)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system trivial))
@@ -88,6 +97,13 @@ cat > "$module_dir/foo.scm"<<EOF
     (synopsis "Dummy package")
     (description "bar is a dummy package for testing.")
     (license #f)))
+
+(define-public baz
+  (dummy-package "baz" (replacement foo)))
+
+(define-public superseded
+  (deprecated-package "superseded" bar))
+
 EOF
 
 GUIX_PACKAGE_PATH="$module_dir"
@@ -97,6 +113,10 @@ export GUIX_PACKAGE_PATH
 guix build -d -S foo
 guix build -d -S foo | grep -e 'foo\.tar\.gz'
 
+# 'baz' has a replacement so we should be getting the replacement's source.
+(unset GUIX_BUILD_OPTIONS;
+ test "`guix build -d -S baz`" = "`guix build -d -S foo`")
+
 guix build -d --sources=package foo
 guix build -d --sources=package foo | grep -e 'foo\.tar\.gz'
 
@@ -118,6 +138,25 @@ test `guix build -d --sources=transitive foo \
       | grep -e 'foo\.tar\.gz' -e 'bar\.tar\.gz' -e 'bar\.dat' \
       | wc -l` -eq 3
 
+
+# Unbound variables.
+cat > "$module_dir/foo.scm"<<EOF
+(define-module (foo)
+  #:use-module (guix tests)
+  #:use-module (guix build-system trivial))
+
+(define-public foo
+  (dummy-package "package-with-something-wrong"
+    (build-system trivial-build-system)
+    (inputs (quasiquote (("sed" ,sed))))))  ;unbound variable
+EOF
+
+if guix build package-with-something-wrong -n; then false; else true; fi
+guix build package-with-something-wrong -n 2> "$module_dir/err" || true
+grep "unbound" "$module_dir/err"                    # actual error
+grep "forget.*(gnu packages base)" "$module_dir/err" # hint
+rm -f "$module_dir"/*
+
 # Should all return valid log files.
 drv="`guix build -d -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
 out="`guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'`"
@@ -148,7 +187,7 @@ rm -f "$result"
 guix build coreutils --target=mips64el-linux-gnu --dry-run --no-substitutes
 
 # Replacements.
-drv1=`guix build guix --with-input=guile=guile-next -d`
+drv1=`guix build guix --with-input=guile@2.0=guile@2.2 -d`
 drv2=`guix build guix -d`
 test "$drv1" != "$drv2"
 
@@ -159,9 +198,12 @@ test "$drv1" = "$drv2"
 if guix build guile --with-input=libunistring=something-really-silly
 then false; else true; fi
 
+# Deprecated/superseded packages.
+test "`guix build superseded -d`" = "`guix build bar -d`"
+
 # Parsing package names and versions.
 guix build -n time             # PASS
-guix build -n time@1.7         # PASS, version found
+guix build -n time@1.9         # PASS, version found
 if guix build -n time@3.2;     # FAIL, version not found
 then false; else true; fi
 if guix build -n something-that-will-never-exist; # FAIL
@@ -179,6 +221,10 @@ guix build -e "(begin
 guix build -e '#~(mkdir #$output)' -d
 guix build -e '#~(mkdir #$output)' -d | grep 'gexp\.drv'
 
+# Same with a file-like object.
+guix build -e '(computed-file "foo" #~(mkdir #$output))' -d
+guix build -e '(computed-file "foo" #~(mkdir #$output))' -d | grep 'foo\.drv'
+
 # Building from a package file.
 cat > "$module_dir/package.scm"<<EOF
 (use-modules (gnu))