From 1261ce15233cbf7e24de9959df86a23b46314a28 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 13 Mar 2023 13:52:38 +0100 Subject: store: Tolerate non-existent GC root directories. * guix/store/roots.scm (gc-roots): Wrap 'scandir*' call in 'catch'. * tests/store-roots.scm ("gc-roots, initial"): New test. Move 'open-connection' call below. --- tests/store-roots.scm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tests') 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 +;;; Copyright © 2019, 2023 Ludovic Courtès ;;; ;;; 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))) -- cgit 1.4.1