diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/guix-package.sh | 12 | ||||
-rw-r--r-- | tests/guix-register.sh | 26 |
2 files changed, 30 insertions, 8 deletions
diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b09a9c0173..5f97aff026 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -79,12 +79,16 @@ then # Search. test "`guix package -s "An example GNU package" | grep ^name:`" = \ "name: hello" - test "`guix package -s "n0t4r341p4ck4g3"`" = "" + test -z "`guix package -s "n0t4r341p4ck4g3"`" # List generations. test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ = " guile-bootstrap" + # Exit with 1 when a generation does not exist. + if guix package -p "$profile" --list-generations=42; + then false; else true; fi + # Remove a package. guix package --bootstrap -p "$profile" -r "guile-bootstrap" test -L "$profile-3-link" @@ -107,11 +111,17 @@ then test "`readlink_base "$profile"`" = "$profile-0-link" done + # Test that '--list-generations' does not output the zeroth generation. + test -z "`guix package -p "$profile" -l 0`" + # Reinstall after roll-back to the empty profile. guix package --bootstrap -p "$profile" -e "$boot_make" test "`readlink_base "$profile"`" = "$profile-1-link" test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" + # Check that the first generation is the current one. + test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)" + # Roll-back to generation 0, and install---all at once. guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap test "`readlink_base "$profile"`" = "$profile-1-link" diff --git a/tests/guix-register.sh b/tests/guix-register.sh index b76a1af54f..ca28fb0d95 100644 --- a/tests/guix-register.sh +++ b/tests/guix-register.sh @@ -38,9 +38,10 @@ cp -r "$to_copy" "$new_store_dir" copied="$new_store_dir/`basename $to_copy`" # Create a file representing a closure with zero references, and with an empty -# "deriver" field. +# "deriver" field. Note that we give the file name as it appears in the +# original store, and 'guix-register' translates it to match the prefix. cat >> "$closure" <<EOF -$copied +$to_copy 0 EOF @@ -49,26 +50,37 @@ EOF guix-register -p "$new_store" < "$closure" # Doing it a second time shouldn't hurt. -guix-register -p "$new_store" "$closure" +guix-register --prefix "$new_store" "$closure" # Now make sure this is recognized as valid. NIX_IGNORE_SYMLINK_STORE=1 NIX_STORE_DIR="$new_store_dir" -NIX_LOCALSTATE_DIR="$new_store$localstatedir" +NIX_STATE_DIR="$new_store$localstatedir" NIX_LOG_DIR="$new_store$localstatedir/log/nix" NIX_DB_DIR="$new_store$localstatedir/nix/db" -export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR NIX_LOCALSTATE_DIR \ +export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR NIX_STATE_DIR \ NIX_LOG_DIR NIX_DB_DIR guix-daemon --disable-chroot & subdaemon_pid=$! exit_hook="kill $subdaemon_pid" +final_name="$storedir/`basename $to_copy`" + # At this point the copy in $new_store must be valid, and unreferenced. +# The database under $new_store uses the $final_name, but we can't use +# that name in a 'valid-path?' query because 'assertStorePath' would kill +# us because of the wrong prefix. So we just list dead paths instead. guile -c " (use-modules (guix store)) (define s (open-connection)) - (exit (and (valid-path? s \"$copied\") - (equal? (list \"$copied\") (dead-paths s))))" + (exit (equal? (list \"$copied\") (dead-paths s)))" + +# When 'sqlite3' is available, check the name in the database. +if type -P sqlite3 +then + echo "select * from ValidPaths where path=\"$final_name\";" | \ + sqlite3 $NIX_DB_DIR/db.sqlite +fi |