diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/guix-home.sh | 7 | ||||
-rwxr-xr-x | tests/guix-locate.sh | 72 | ||||
-rw-r--r-- | tests/packages.scm | 17 | ||||
-rw-r--r-- | tests/store-roots.scm | 18 |
4 files changed, 110 insertions, 4 deletions
diff --git a/tests/guix-home.sh b/tests/guix-home.sh index e9ef76c862..e6d16d7fab 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -1,7 +1,7 @@ # GNU Guix --- Functional package management for GNU # Copyright © 2021-2023 Andrew Tropin <andrew@trop.in> # Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> -# Copyright © 2022 Ludovic Courtès <ludo@gnu.org> +# Copyright © 2022, 2023 Ludovic Courtès <ludo@gnu.org> # # This file is part of GNU Guix. # @@ -94,6 +94,9 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT (home-bash-extension (environment-variables '(("PS1" . "$GUIX_ENVIRONMENT λ "))) + (aliases + `(("run" . "guix shell") + ("path" . ,(literal-string "echo $PATH")))) (bashrc (list (plain-file @@ -149,6 +152,8 @@ EOF test -d "${HOME}/.guix-home" test -h "${HOME}/.bash_profile" test -h "${HOME}/.bashrc" + grep 'alias run="guix shell"' "$HOME/.bashrc" + grep "alias path='echo \$PATH'" "$HOME/.bashrc" test "$(tail -n 2 "${HOME}/.bashrc")" == "\ # dot-bashrc test file for guix home # the content of bashrc-test-config.sh" diff --git a/tests/guix-locate.sh b/tests/guix-locate.sh new file mode 100755 index 0000000000..43f8ba53b0 --- /dev/null +++ b/tests/guix-locate.sh @@ -0,0 +1,72 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2023 Antoine R. Dumont <antoine.romain.dumont@gmail.com> +# 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 locate' command-line utility. +# + +set -x + +RUN_EXPENSIVE_TESTS="${RUN_EXPENSIVE_TESTS:-false}" + +tmpdir="guix-index-$$" +# In the following tests, we use two different databases, one for each +# indexation method. +tmpdb_manifests="$tmpdir/manifests/db.sqlite" +tmpdb_store="$tmpdir/store/db.sqlite" +trap 'rm -rf "$tmpdir" "$tmpdb_store" "$tmpdb_manifests"' EXIT + +guix locate --version + +# Preparing db locations for both indexation methods. +mkdir -p "$(dirname "$tmpdb_manifests")" "$(dirname "$tmpdb_store")" + +cmd_manifests="guix locate --database=$tmpdb_manifests --method=manifests" +cmd_store="guix locate --database=$tmpdb_store --method=store" + +# Lookup without any db should fail. +guix locate --database="$tmpdb_manifests" guile && false +guix locate --database="$tmpdb_store" guile && false + +# Lookup without anything in db should yield no results because the indexer +# didn't stumble upon any profile. +test -z "$(guix locate --database="$tmpdb_manifests" guile)" + +# Install a package. +guix package --bootstrap --install guile-bootstrap \ + --profile="$tmpdir/profile" + +# Look for 'guile'. +$cmd_manifests --update +$cmd_manifests guile | grep "$(guix build guile-bootstrap)/bin/guile" +$cmd_manifests boot-9.scm | grep ^guile-bootstrap + +# Using a glob pattern. +$cmd_manifests -g '*.scm' | grep "^guile-bootstrap.*boot-9" + +# Statistics. +$cmd_manifests --stats + +if $RUN_EXPENSIVE_TESTS +then + $cmd_store --update + $cmd_store guile + $cmd_store guile | grep "$(guix build guile-bootstrap)/bin/guile" + $cmd_store boot-9.scm | grep ^guile-bootstrap +fi diff --git a/tests/packages.scm b/tests/packages.scm index 5e8eac99dc..2b7ab01f7d 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -368,6 +368,23 @@ (package-transitive-supported-systems d) (package-transitive-supported-systems e)))) +(test-equal "package-transitive-supported-systems detects cycles" + '("c" "a" "b" "c") + (letrec* ((a (dummy-package "a" + (build-system trivial-build-system) + (native-inputs (list c)))) + (b (dummy-package "b" + (build-system trivial-build-system) + (inputs (list a)))) + (c (dummy-package "c" + (build-system trivial-build-system) + (inputs (list b))))) + (guard (c ((package-cyclic-dependency-error? c) + (map package-name + (cons (package-error-package c) + (package-error-dependency-cycle c))))) + (package-transitive-supported-systems c)))) + (test-assert "package-development-inputs" ;; Note: Due to propagated inputs, 'package-development-inputs' returns a ;; couple more inputs, such as 'linux-libre-headers'. diff --git a/tests/store-roots.scm b/tests/store-roots.scm index 5bcf1bc87e..9877987a65 100644 --- a/tests/store-roots.scm +++ b/tests/store-roots.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2019, 2023 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,14 +21,26 @@ #:use-module (guix store) #:use-module (guix store roots) #:use-module ((guix utils) #:select (call-with-temporary-directory)) + #:use-module ((guix build utils) #:select (delete-file-recursively)) + #:use-module ((guix config) #:select (%state-directory)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64)) -(define %store - (open-connection)) +(define %store #f) (test-begin "store-roots") +(test-equal "gc-roots, initial" + (list (string-append %state-directory "/profiles")) + (begin + ;; 'gc-roots' should gracefully handle lack of that directory. + (delete-file-recursively (string-append %state-directory "/profiles")) + (gc-roots))) + +;; The 'open-connection' call below gets guix-daemon to create +;; %STATE-DIRECTORY/profiles. +(set! %store (open-connection)) + (test-assert "gc-roots, regular root" (let* ((item (add-text-to-store %store "something" (random-text))) |