summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2023-01-08 19:32:17 +0100
committerMarius Bakke <marius@gnu.org>2023-01-08 19:32:17 +0100
commitda91e790fdf4053a1503738e69f88c4b2054b096 (patch)
tree27f26ac3308eaa34952314a3182ffce2f5dcd51e /tests
parent9123bb0fba3fce976dc41cd3b8919ee73b4cee4d (diff)
parent8cca1a35bc42cddb7e0586062d192197520042d5 (diff)
Merge branch 'master' into staging
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-home.sh4
-rw-r--r--tests/guix-refresh.sh117
2 files changed, 120 insertions, 1 deletions
diff --git a/tests/guix-home.sh b/tests/guix-home.sh
index d5e2dadbb5..423ebf6f33 100644
--- a/tests/guix-home.sh
+++ b/tests/guix-home.sh
@@ -81,7 +81,8 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
(simple-service 'add-environment-variable
home-environment-variables-service-type
- '(("TODAY" . "26 messidor")))
+ `(("TODAY" . "26 messidor")
+ ("LITERAL" . ,(literal-string "${abc}"))))
(simple-service 'home-bash-service-extension-test
home-bash-service-type
@@ -149,6 +150,7 @@ EOF
grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf"
grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile"
( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" )
+ ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' )
# This one should still be here.
grep "stay around" "$HOME/.config/random-file"
diff --git a/tests/guix-refresh.sh b/tests/guix-refresh.sh
new file mode 100644
index 0000000000..d9f13bac3a
--- /dev/null
+++ b/tests/guix-refresh.sh
@@ -0,0 +1,117 @@
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+#
+# Test the 'guix refresh' command-line utility.
+#
+
+guix refresh --version
+
+manifest="t-guix-refresh-manifest-$$.scm"
+module_dir="t-guix-refresh-modules-$$"
+trap 'rm -f "$manifest"; rm -rf "$module_dir"' EXIT
+
+# Tell the 'test' updater what to simulate.
+export GUIX_TEST_UPDATER_TARGETS
+idutils_version="$(guix package -A ^idutils$ | cut -f2)"
+GUIX_TEST_UPDATER_TARGETS='
+ (("guile" "3" (("12.5" "file:///dev/null")
+ ("1.6.4" "file:///dev/null")))
+ ("libreoffice" "" (("1.0" "file:///dev/null")))
+ ("idutils" "" (("'$idutils_version'" "file:///dev/null")))
+ ("the-test-package" "" (("5.5" "file://'$PWD/$module_dir'/source"))))'
+
+# No newer version available.
+! guix refresh -t test idutils
+case "$(guix refresh -t test idutils 2>&1)" in
+ *"$idutils_version"*"already the latest version"*) true;;
+ *) false;;
+esac
+! guix refresh -t test libreoffice
+case "$(guix refresh -t test libreoffice 2>&1)" in
+ *"greater than the latest known version"*"1.0"*) true;;
+ *) false;;
+esac
+
+# Various ways to specify packages.
+cat > "$manifest" <<EOF
+(specifications->manifest (list "guile@3.0"))
+EOF
+default_IFS="$IFS"
+IFS=_
+for spec in "guile" \
+ "guile@3.0" \
+ "-e_(@ (gnu packages guile) guile-3.0)" \
+ "-m_$manifest" \
+ "-r_guile" \
+ "-s_core"
+do
+ guix refresh -t test $spec
+ case "$(guix refresh -t test $spec 2>&1)" in
+ *"would be upgraded"*"12.5"*)
+ true;;
+ *)
+ false;;
+ esac
+done
+IFS="$default_IFS"
+
+# Actually updating.
+mkdir "$module_dir"
+echo hello > "$module_dir/source"
+cat > "$module_dir/sample.scm"<<EOF
+(define-module (sample)
+ #:use-module (guix packages)
+ #:use-module (guix download)
+ #:use-module (gnu packages base))
+
+(define-public my-thing
+ (package
+ (inherit hello)
+ (name "the-test-package")
+ (version "4.3")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "mirror://gnu/hello/hello-" version
+ ".tar.gz"))
+ (sha256
+ (base32
+ "086vqwk2wl8zfs47sq2xpjc9k066ilmb8z6dn0q6ymwjzlm196cd"))))))
+EOF
+guix refresh -t test -L "$module_dir" the-test-package
+guix refresh -t test -L "$module_dir" the-test-package -u
+grep 'version "5.5"' "$module_dir/sample.scm"
+grep "$(guix hash -H sha256 -f nix-base32 "$module_dir/source")" "$module_dir/sample.scm"
+
+# Specifying a target version.
+! guix refresh -t test guile=2.0.0
+case "$(guix refresh -t test guile=2.0.0 2>&1)" in
+ *"failed to find"*"2.0.0"*) true;;
+ *) false;;
+esac
+for spec in "guile=1.6.4" "guile@3=1.6.4"
+do
+ guix refresh -t test "$spec"
+ case "$(guix refresh -t test "$spec" 2>&1)" in
+ *"would be downgraded"*"1.6.4"*) true;;
+ *) false;;
+ esac
+done
+
+# Listing updaters. This should work whether or not networking is available.
+guix refresh --list-updaters