diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh
index 08c97cbb6577e37b5a4949671e98b11ddc9473f3..32faf71a4eb4a879a22f879ac51eb7b12b875d51 100644
--- a/tests/guix-environment.sh
+++ b/tests/guix-environment.sh
@@ -39,6 +39,14 @@ test "`wc -l < "$tmpdir/a"`" = 1
 
 cmp "$tmpdir/a" "$tmpdir/b"
 
+# Make sure the exit value is preserved.
+if guix environment --ad-hoc guile-bootstrap --pure -E 'guile -c "(exit 42)"'
+then
+    false
+else
+    test $? = 42
+fi
+
 if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
 then
     # Compute the build environment for the initial GNU Make.