From ac435c14a627f620bf6719efbdd214a12b33716e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 20 Nov 2020 11:35:23 +0100 Subject: store-database: Add test checking the directory mtime after 'register-path'. * tests/store-database.scm ("register-path, directory"): New test. --- tests/store-database.scm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/store-database.scm b/tests/store-database.scm index 4d91884250..3b4ef43f6d 100644 --- a/tests/store-database.scm +++ b/tests/store-database.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2017, 2018 Ludovic Courtès +;;; Copyright © 2017, 2018, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +21,8 @@ (define-module (test-store-database) #:use-module (guix store) #:use-module (guix store database) #:use-module ((guix utils) #:select (call-with-temporary-output-file)) + #:use-module ((guix build utils) + #:select (mkdir-p delete-file-recursively)) #:use-module (srfi srfi-26) #:use-module (srfi srfi-64)) @@ -55,6 +57,28 @@ (define %store (list (stat:mtime (lstat file)) (stat:mtime (lstat ref))))))) +(test-equal "register-path, directory" + '(1 1 1) + (let ((file (string-append (%store-prefix) "/" (make-string 32 #\f) + "-fake-directory"))) + (when (valid-path? %store file) + (delete-paths %store (list file))) + (false-if-exception (delete-file-recursively file)) + + (let ((drv (string-append file ".drv"))) + (mkdir-p (string-append file "/a")) + (call-with-output-file (string-append file "/a/b") + (const #t)) + (register-path file #:deriver drv) + + (and (valid-path? %store file) + (null? (references %store file)) + (null? (valid-derivers %store file)) + (null? (referrers %store file)) + (list (stat:mtime (lstat file)) + (stat:mtime (lstat (string-append file "/a"))) + (stat:mtime (lstat (string-append file "/a/b")))))))) + (test-equal "new database" (list 1 2) (call-with-temporary-output-file -- cgit v1.2.3