aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-11-20 11:35:23 +0100
committerLudovic Courtès <ludo@gnu.org>2020-11-21 12:39:14 +0100
commitac435c14a627f620bf6719efbdd214a12b33716e (patch)
tree39086e15adb216a26088249a51e109aaa1cd5ac4 /tests
parent2200bb214690ebc78b9fa42887ac9dfb8035bd4f (diff)
downloadguix-ac435c14a627f620bf6719efbdd214a12b33716e.tar
guix-ac435c14a627f620bf6719efbdd214a12b33716e.tar.gz
store-database: Add test checking the directory mtime after 'register-path'.
* tests/store-database.scm ("register-path, directory"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/store-database.scm26
1 files changed, 25 insertions, 1 deletions
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 <ludo@gnu.org>
+;;; Copyright © 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,6 +21,8 @@
#: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 @@
(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