diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/guix-home.sh | 2 | ||||
-rw-r--r-- | tests/guix-shell-export-manifest.sh | 85 | ||||
-rw-r--r-- | tests/lint.scm | 11 | ||||
-rw-r--r-- | tests/packages.scm | 13 | ||||
-rw-r--r-- | tests/services.scm | 37 | ||||
-rw-r--r-- | tests/style.scm | 9 |
6 files changed, 144 insertions, 13 deletions
diff --git a/tests/guix-home.sh b/tests/guix-home.sh index 0f68484ef4..8a7048a9ca 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -69,7 +69,7 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT (list (simple-service 'test-config home-files-service-type - (list `("config/test.conf" + (list `(".config/test.conf" ,(plain-file "tmp-file.txt" "the content of ~/.config/test.conf")))) diff --git a/tests/guix-shell-export-manifest.sh b/tests/guix-shell-export-manifest.sh new file mode 100644 index 0000000000..f83904deb4 --- /dev/null +++ b/tests/guix-shell-export-manifest.sh @@ -0,0 +1,85 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2022 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 'guix shell --export-manifest'. +# + +guix shell --version + +tmpdir="t-guix-manifest-$$" +trap 'rm -r "$tmpdir"' EXIT +mkdir "$tmpdir" + +manifest="$tmpdir/manifest.scm" + +# Basics. +guix shell --export-manifest guile-bootstrap > "$manifest" +test "$(guix build -m "$manifest")" = "$(guix build guile-bootstrap)" + +guix shell -m "$manifest" --bootstrap -- \ + "$SHELL" -c 'guix package --export-manifest -p "$GUIX_ENVIRONMENT"' > \ + "$manifest.second" +for m in "$manifest" "$manifest.second" +do + grep -v '^;' < "$m" > "$m.new" # filter out comments + mv "$m.new" "$m" +done + +cat "$manifest" +cat "$manifest.second" + +cmp "$manifest" "$manifest.second" + +# Combining manifests. +guix shell --export-manifest -m "$manifest" gash gash-utils \ + > "$manifest.second" +guix build -m "$manifest.second" -d | \ + grep "$(guix build guile-bootstrap -d)" +guix build -m "$manifest.second" -d | \ + grep "$(guix build gash -d)" + +# Package transformation option. +guix shell --export-manifest guile guix \ + --with-input=guile-json@3=guile-json > "$manifest" +grep 'options->transformation' "$manifest" +grep '(with-input . "guile-json@3=guile-json")' "$manifest" + +# Development manifest. +guix shell --export-manifest -D guile git > "$manifest" +grep 'package->development-manifest' "$manifest" +grep '"guile"' "$manifest" +guix build -m "$manifest" -d | \ + grep "$(guix build -e '(@@ (gnu packages commencement) gcc-final)' -d)" +guix build -m "$manifest" -d | \ + grep "$(guix build git -d)" + +# Test various combinations to make sure generated code uses interfaces +# correctly. +for options in \ + "coreutils grep sed" \ + "gsl openblas gcc-toolchain --tune" \ + "guile -m $manifest.previous" \ + "git:send-email gdb guile:debug" \ + "git -D coreutils" +do + guix shell --export-manifest $options > "$manifest" + cat "$manifest" + guix shell -m "$manifest" -n + mv "$manifest" "$manifest.previous" +done diff --git a/tests/lint.scm b/tests/lint.scm index 6bb24370da..8be74d2604 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -5,7 +5,7 @@ ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> ;;; Copyright © 2017 Alex Kost <alezost@gmail.com> -;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il> +;;; Copyright © 2017, 2022 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net> ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com> ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr> @@ -1102,6 +1102,15 @@ (single-lint-warning-message (check-mirror-url (dummy-package "x" (source source)))))) +(test-equal "mirror-url: kde suggestion" + "URL should be 'mirror://kde/stable/gcompris/qt/src/gcompris-qt-2.3.tar.xz'" + (let ((source (origin + (method url-fetch) + (uri "https://download.kde.org/stable/gcompris/qt/src/gcompris-qt-2.3.tar.xz") + (sha256 %null-sha256)))) + (single-lint-warning-message + (check-mirror-url (dummy-package "x" (source source)))))) + (test-equal "github-url" '() (with-http-server `((200 ,%long-string)) diff --git a/tests/packages.scm b/tests/packages.scm index 710eace6dc..6cbc34ba0b 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1923,6 +1923,19 @@ (package-location (specification->package "guile@2")) (specification->location "guile@2")) +(test-equal "package-unique-version-prefix, gcc@8" + "8" + (let ((gcc (specification->package "gcc-toolchain@8"))) + (package-unique-version-prefix (package-name gcc) + (package-version gcc)))) + +(test-equal "package-unique-version-prefix, grep" + "" + (let ((grep (specification->package "grep"))) + (package-unique-version-prefix (package-name grep) + (package-version grep)))) + + (test-eq "this-package-input, exists" hello (package-arguments diff --git a/tests/services.scm b/tests/services.scm index 572fe38164..e64b3e8de8 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2015-2019, 2022 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -212,9 +212,9 @@ ;; because it is not currently running. 'baz' is loaded because it's ;; a new service. (shepherd-service-upgrade - (list (live-service '(foo) '() #t) - (live-service '(bar) '() #f) - (live-service '(root) '() #t)) ;essential! + (list (live-service '(foo) '() #f #t) + (live-service '(bar) '() #f #f) + (live-service '(root) '() #f #t)) ;essential! (list (shepherd-service (provision '(foo)) (start #t)) (shepherd-service (provision '(bar)) @@ -234,9 +234,9 @@ ;; unloaded because 'foo' depends on it. 'foo' gets replaced but it ;; must be restarted manually. (shepherd-service-upgrade - (list (live-service '(foo) '(bar) #t) - (live-service '(bar) '() #t) ;still used! - (live-service '(baz) '() #t)) + (list (live-service '(foo) '(bar) #f #t) + (live-service '(bar) '() #f #t) ;still used! + (live-service '(baz) '() #f #t)) (list (shepherd-service (provision '(foo)) (start #t))))) (lambda (unload restart) @@ -251,9 +251,26 @@ ;; 'foo', 'bar', and 'baz' depend on each other, but all of them are ;; obsolete, and thus should be unloaded. (shepherd-service-upgrade - (list (live-service '(foo) '(bar) #t) ;obsolete - (live-service '(bar) '(baz) #t) ;obsolete - (live-service '(baz) '() #t)) ;obsolete + (list (live-service '(foo) '(bar) #f #t) ;obsolete + (live-service '(bar) '(baz) #f #t) ;obsolete + (live-service '(baz) '() #f #t)) ;obsolete + (list (shepherd-service (provision '(qux)) + (start #t))))) + (lambda (unload restart) + (list (map live-service-provision unload) + (map shepherd-service-provision restart))))) + +(test-equal "shepherd-service-upgrade: transient service" + ;; Transient service must not be unloaded: + ;; <https://issues.guix.gnu.org/54812>. + '(((foo)) ;unload + ((qux))) ;restart + (call-with-values + (lambda () + (shepherd-service-upgrade + (list (live-service '(sshd-42) '() #t 42) ;transient + (live-service '(foo) '() #f #t) ;obsolete + (live-service '(qux) '() #f #t)) ;running (list (shepherd-service (provision '(qux)) (start #t))))) (lambda (unload restart) diff --git a/tests/style.scm b/tests/style.scm index 8c6d37a661..41f7e31cce 100644 --- a/tests/style.scm +++ b/tests/style.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -377,7 +377,14 @@ (list (package-inputs (@ (my-packages) my-coreutils)) (read-package-field (@ (my-packages) my-coreutils) 'inputs 4))))) +(test-equal "read-with-comments: dot notation" + (cons 'a 'b) + (call-with-input-string "(a . b)" + read-with-comments)) + (test-pretty-print "(list 1 2 3 4)") +(test-pretty-print "((a . 1) (b . 2))") +(test-pretty-print "(a b c . boom)") (test-pretty-print "(list 1 2 3 |