aboutsummaryrefslogtreecommitdiff
path: root/tests/cache.scm
blob: 80b44d69aadf30c3f813169578e96591d026fd9b (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2020 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/>.

(define-module (test-cache)
  #:use-module (guix cache)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-19)
  #:use-module (srfi srfi-64)
  #:use-module ((guix utils) #:select (call-with-temporary-directory))
  #:use-module (ice-9 match))

(test-begin "cache")

(test-equal "remove-expired-cache-entries"
  '("o" "l" "d")
  (let* ((removed '())
         (now     (time-second (current-time time-monotonic)))
         (ttl     100)
         (stamp   (match-lambda
                    ((or "n" "e" "w") (+ now 100))
                    ((or "o" "l" "d") (- now 100))))
         (delete  (lambda (entry)
                    (set! removed (cons entry removed)))))
    (remove-expired-cache-entries (reverse '("n" "e" "w"
                                             "o" "l" "d"))
                                  #:entry-expiration stamp
                                  #:delete-entry delete)
    removed))

(define-syntax-rule (test-cache-cleanup cache exp ...)
  (call-with-temporary-directory
   (lambda (cache)
     (let* ((deleted '())
            (delete! (lambda (entry)
                       (set! deleted (cons entry deleted)))))
       exp ...
       (maybe-remove-expired-cache-entries cache
                                           (const '("a" "b" "c"))
                                           #:entry-expiration (const 0)
                                           #:delete-entry delete!)
       (reverse deleted)))))

(test-equal "maybe-remove-expired-cache-entries, first cleanup"
  '("a" "b" "c")
  (test-cache-cleanup cache))

(test-equal "maybe-remove-expired-cache-entries, no cleanup needed"
  '()
  (test-cache-cleanup cache
    (call-with-output-file (string-append cache "/last-expiry-cleanup")
      (lambda (port)
        (display (+ (time-second (current-time time-monotonic)) 100)
                 port)))))

(test-equal "maybe-remove-expired-cache-entries, cleanup needed"
  '("a" "b" "c")
  (test-cache-cleanup cache
    (call-with-output-file (string-append cache "/last-expiry-cleanup")
      (lambda (port)
        (display 0 port)))))

(test-end "cache")

;;; Local Variables:
;;; eval: (put 'test-cache-cleanup 'scheme-indent-function 1)
;;; End:
ffice.scm (libetonyek)[arguments]: Likewise. * gnu/packages/libusb.scm (hidapi)[arguments]: Likewise. * gnu/packages/linux.scm (gpm)[arguments]: Likewise. * gnu/packages/logging.scm (glog)[arguments]: Likewise. * gnu/packages/machine-learning.scm (ghmm)[arguments]: Likewise. * gnu/packages/mail.scm (dovecot-trees, dovecot-libsodium-plugin, esmtp) [arguments]: Likewise. * gnu/packages/messaging.scm (freetalk, libmesode, libstrophe)[arguments]: Likewise. * gnu/packages/microcom.scm (microcom)[arguments]: Likewise. * gnu/packages/ocaml.scm (ocaml-ssl)[arguments]: Likewise. * gnu/packages/parallel.scm (slurm)[arguments]: Likewise. * gnu/packages/pdf.scm (libharu)[arguments]: Likewise. * gnu/packages/samba.scm (cifs-utils)[arguments]: Likewise. * gnu/packages/serialization.scm (msgpack)[arguments]: Likewise. * gnu/packages/shells.scm (scsh)[arguments]: Likewise. * gnu/packages/telephony.scm (libiax2)[arguments]: Likewise. * gnu/packages/textutils.scm (dotconf)[arguments]: Likewise. * gnu/packages/version-control.scm (findnewest)[arguments]: Likewise. * gnu/packages/video.scm (libmediainfo, mediainfo)[arguments]: Likewise. Kei Kebreau 2017-08-27gnu: Fetch several Git sources over HTTPS....* gnu/packages/admin.scm (interrobang)[source]: Use HTTPS URL. * gnu/packages/audio.scm (ardour)[source]: Likewise. * gnu/packages/embedded.scm (libjaylink, openocd)[source]: Likewise. * gnu/packages/gnome.scm (byzanz)[source]: Likewise. * gnu/packages/gnunet.scm (guile-gnunet)[source]Likewise. * gnu/packages/java.scm (classpath)[source]: Likewise. * gnu/packages/microcom.scm (microcom)[source]: Likewise. * gnu/packages/python.scm (python-axolotl-curve25519)[source]: Likewise. * gnu/packages/rdesktop.scm (freerdp)[source]: Likewise. * gnu/packages/shells.scm (rc)[source]: Likewise. * gnu/packages/web.scm (libwebsockets)[source]: Use new source URL. Leo Famulari 2017-08-07Merge branch 'master' into core-updatesMark H Weaver 2017-08-07gnu: propeller-gcc-4: Don't build on aarch64-linux....* gnu/packages/embedded.scm (propeller-gcc-4)[supported-system]: New field. Efraim Flashner 2017-06-26Merge branch 'master' into core-updatesMark H Weaver 2017-06-21gnu: propeller-gcc: Default to version 4....* gnu/packages/embedded.scm (propeller-gcc): Rename this... (propeller-gcc-6): ...to this. (propeller-gcc-4): Inherit from propeller-gcc-6. (propeller-gcc): New alias for propeller-gcc-4. Ricardo Wurmus 2017-06-20Merge branch 'master' into core-updatesMark H Weaver 2017-06-18gnu: propeller-gcc-4: Add cross environment variables patch....* gnu/packages/embedded.scm (propeller-gcc-4)[source]: Add gcc-cross-environment-variables.patch. Ricardo Wurmus 2017-06-18Merge branch 'master' into core-updatesMark H Weaver 2017-06-16gnu: spin2cpp: Update to 3.6.3....* gnu/packages/embedded.scm (spin2cpp): Update to 3.6.3. Tobias Geerinckx-Rice 2017-06-15gnu: Add propeller-gcc-4....* gnu/packages/embedded.scm (propeller-gcc-4): New variable. * gnu/packages/patches/gcc-4.6-gnu-inline.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Ricardo Wurmus 2017-05-27Merge branch 'master' into core-updatesMark H Weaver 2017-05-24gnu: arm-none-eabi-toolchain: Include libstdc++....* gnu/packages/embedded.scm (arm-none-eabi-toolchain)[propagated-inputs]: Add libstdc++. Ricardo Wurmus 2017-05-24gnu: arm-none-eabi-toolchain: Provide union of all inputs at the output....* gnu/packages/embedded.scm (arm-none-eabi-toolchain)[arguments]: Make the union of all inputs available at the output. Ricardo Wurmus 2017-05-24gnu: Add libstdc++-arm-none-eabi....* gnu/packages/embedded.scm (make-libstdc++-arm-none-eabi): New procedure. Ricardo Wurmus 2017-05-24gnu: Allow overriding of xgcc package in cross-gcc....* gnu/packages/cross-base.scm (cross-gcc-arguments): Take extra "xgcc" argument. (cross-gcc): Use keyword arguments; take optional "xgcc" argument. * gnu/packages/embedded.scm (gcc-arm-none-eabi-4.9, propeller-gcc, gcc-vc4): Use keyword arguments. * gnu/packages/avr.scm (avr-gcc-4.9): Likewise. Ricardo Wurmus 2017-05-24Merge branch 'master' into core-updatesRicardo Wurmus 2017-05-15gnu: flex-2.6.1: Remove variable....* gnu/packages/flex.scm (flex-2.6.1): Remove variable. * gnu/packages/bootloaders.scm (grub, dtc): Use flex instead of flex-2.6.1. * gnu/packages/embedded.scm (propeller-binutils, binutils-vc4): Likewise. * gnu/packages/maths.scm (scotch): Likewise. * gnu/packages/wine.scm (wine): Likewise. Leo Famulari 2017-05-01gnu: Add gcc-vc4....Fixes <https://bugs.gnu.org/26541>. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add vc4-elf. * gnu/packages/embedded.scm (gcc-vc4): New variable. Danny Milosavljevic 2017-03-30gnu: propeller-binutils: Use flex 2.6.1....* gnu/packages/embedded.scm (propeller-binutils)[native-inputs]: Replace "flex" with "flex-2.6.1". Ricardo Wurmus 2017-03-23Merge remote-tracking branch 'origin/master' into core-updatesEfraim Flashner 2017-03-22gnu: binutils-vc4: Build with flex-2.6.1....* gnu/packages/embedded.scm (binutils-vc4)[native-inputs]: Use flex-2.6.1 and not flex. Efraim Flashner 2017-03-22gnu: binutils-vc4: Set source file-name....* gnu/packages/embedded.scm (binutils-vc4)[source]: Add file-name field. Efraim Flashner 2017-03-05gnu: Add binutils-vc4....* gnu/packages/embedded.scm (binutils-vc4): New variable. Danny Milosavljevic 2017-01-01gnu: Add propeller-development-suite....* gnu/packages/embedded.scm (propeller-development-suite): New variable. Ricardo Wurmus 2017-01-01gnu: Add spinsim....* gnu/packages/embedded.scm (spinsim): New variable. Ricardo Wurmus 2017-01-01gnu: Add spin2cpp....* gnu/packages/embedded.scm (spin2cpp): New variable. Ricardo Wurmus 2017-01-01gnu: Add propeller-load....* gnu/packages/embedded.scm (propeller-load): New variable. Ricardo Wurmus 2017-01-01gnu: Add openspin....* gnu/packages/embedded.scm (openspin): New variable. Ricardo Wurmus 2017-01-01gnu: Add propeller-toolchain....* gnu/packages/embedded.scm (propeller-toolchain): New variable. Ricardo Wurmus 2017-01-01gnu: Add proplib....* gnu/packages/embedded.scm (proplib): New variable. Ricardo Wurmus 2017-01-01gnu: Add propeller-gcc....* gnu/packages/embedded.scm (propeller-gcc): New variable. Ricardo Wurmus 2017-01-01gnu: Add propeller-binutils....* gnu/packages/embedded.scm (propeller-binutils): New variable. Ricardo Wurmus