epiphany w/ gtk4 and webkitgtk 2.38
[jackhill/guix/guix.git] / tests / guix-build.sh
index 6c08857..9cbf8fe 100644 (file)
@@ -1,6 +1,7 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012-2014, 2016-2022 Ludovic Courtès <ludo@gnu.org>
 # Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
+# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
 #
 # This file is part of GNU Guix.
 #
 guix build --version
 
 # Should fail.
-if guix build -e +;
-then false; else true; fi
+! guix build -e +
 
 # 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`" = ""
 
+# Warn when attempting to build an unsupported package.
+case "$(guix build intelmetool -s armhf-linux -v0 -n 2>&1)" in
+    *warning:*intelmetool*support*armhf*)
+       true
+       break;;
+    *)
+       false;
+       break;;
+esac
+
 # Should pass.
 guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' |       \
     grep -e '-guile-'
@@ -62,8 +72,9 @@ guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
 test `guix build sed -s x86_64-linux -d | wc -l` = 1
 
 # Passing multiple '-s' flags.
-all_systems="-s x86_64-linux -s i686-linux -s armhf-linux -s aarch64-linux"
-test `guix build sed $all_systems -d | sort -u | wc -l` = 4
+all_systems="-s x86_64-linux -s i686-linux -s armhf-linux -s aarch64-linux \
+-s powerpc64le-linux"
+test `guix build sed $all_systems -d | sort -u | wc -l` = 5
 
 # Check there's no weird memoization effect leading to erroneous results.
 # See <https://bugs.gnu.org/40482>.
@@ -76,6 +87,16 @@ module_dir="t-guix-build-$$"
 mkdir "$module_dir"
 trap "rm -rf $module_dir" EXIT
 
+# Check error reporting for '-f'.
+cat > "$module_dir/foo.scm" <<EOF
+(use-modules (guix))
+) ;extra closing paren
+EOF
+! guix build -f "$module_dir/foo.scm" 2> "$module_dir/stderr"
+grep "read error" "$module_dir/stderr"
+rm "$module_dir/stderr" "$module_dir/foo.scm"
+
+# Check 'GUIX_PACKAGE_PATH' & co.
 cat > "$module_dir/foo.scm"<<EOF
 (define-module (foo)
   #:use-module (guix tests)
@@ -178,7 +199,7 @@ cat > "$module_dir/foo.scm" <<EOF
     (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
 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
@@ -199,6 +220,33 @@ grep "forget.*(guix build-system gnu)" "$module_dir/err" # hint
 
 rm -f "$module_dir"/*
 
+# Unbound variable: don't suggest modules that do not export the variable.
+cat > "$module_dir/aa-private.scm" <<EOF
+(define-module (aa-private))
+(define make-thing #f)
+(set! make-thing make-thing)   ;don't inline
+EOF
+
+cat > "$module_dir/bb-public.scm" <<EOF
+(define-module (bb-public) #:export (make-thing))
+(define make-thing identity)
+EOF
+
+cat > "$module_dir/cc-user.scm" <<EOF
+;; Make those module available in the global name space.
+(load-from-path "aa-private.scm")
+(load-from-path "bb-public.scm")
+
+(define-module (cc-user))
+(make-thing 42)
+EOF
+! guix build -f "$module_dir/cc-user.scm" -n 2> "$module_dir/err"
+cat "$module_dir/err"
+grep "make-thing.*unbound" "$module_dir/err"            # actual error
+grep "forget.*(bb-public)" "$module_dir/err"            # hint
+
+rm -f "$module_dir"/*
+
 # Wrong 'define-module' clause reported by 'warn-about-load-error'.
 cat > "$module_dir/foo.scm" <<EOF
 (define-module (something foo)
@@ -222,7 +270,7 @@ test "`guix build --log-file guile-bootstrap`" = "$log"
 test "`guix build --log-file $out`" = "$log"
 
 # Should fail because the name/version combination could not be found.
-if guix build hello-0.0.1 -n; then false; else true; fi
+! guix build hello-0.0.1 -n
 
 # Keep a symlink to the result, registered as a root.
 result="t-result-$$"
@@ -231,8 +279,7 @@ guix build -r "$result"                                     \
 test -x "$result/bin/guile"
 
 # Should fail, because $result already exists.
-if guix build -r "$result" -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
-then false; else true; fi
+! guix build -r "$result" -e '(@@ (gnu packages bootstrap) %bootstrap-guile)'
 
 rm -f "$result"
 
@@ -251,7 +298,7 @@ guix build --target=arm-linux-gnueabihf --dry-run \
      -e '(@ (gnu packages base) coreutils)'
 
 # Replacements.
-drv1=`guix build guix --with-input=guile@2.0=guile@2.2 -d`
+drv1=`guix build guix --with-input=guile-zstd=idutils -d`
 drv2=`guix build guix -d`
 test "$drv1" != "$drv2"
 
@@ -259,8 +306,24 @@ drv1=`guix build guile -d`
 drv2=`guix build guile --with-input=gimp=ruby -d`
 test "$drv1" = "$drv2"
 
-if guix build guile --with-input=libunistring=something-really-silly
-then false; else true; fi
+# See <https://bugs.gnu.org/42156>.
+drv1=`guix build glib -d`
+drv2=`guix build glib -d --with-input=libreoffice=inkscape`
+test "$drv1" = "$drv2"
+
+# '--with-graft' should have no effect when using '--no-grafts'.
+# See <https://bugs.gnu.org/43890>.
+drv1=`guix build inkscape -d --no-grafts`
+drv2=`guix build inkscape -d --no-grafts --with-graft=glib=glib-networking`
+test "$drv1" = "$drv2"
+
+# Rewriting implicit inputs.
+drv1=`guix build hello -d`
+drv2=`guix build hello -d --with-input=gcc=gcc-toolchain`
+test "$drv1" != "$drv2"
+guix gc -R "$drv2" | grep `guix build -d gcc-toolchain`
+
+! guix build guile --with-input=libunistring=something-really-silly
 
 # Deprecated/superseded packages.
 test "`guix build superseded -d`" = "`guix build bar -d`"
@@ -268,10 +331,8 @@ test "`guix build superseded -d`" = "`guix build bar -d`"
 # Parsing package names and versions.
 guix build -n time             # PASS
 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
-then false; else true; fi
+! guix build -n time@3.2       # FAIL, version not found
+! guix build -n something-that-will-never-exist # FAIL
 
 # Invoking a monadic procedure.
 guix build -e "(begin
@@ -343,5 +404,4 @@ export GUIX_BUILD_OPTIONS
 guix build emacs
 
 GUIX_BUILD_OPTIONS="--something-completely-crazy"
-if guix build emacs;
-then false; else true; fi
+! guix build emacs