[functional-tests] with-temp-file-sized now takes *either* bytes or a disk-size object

This commit is contained in:
Joe Thornber 2018-04-18 15:12:28 +01:00
parent 582e424560
commit 1172b2f450
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,7 @@
(library (library
(disk-units) (disk-units)
(export bytes (export disk-size?
bytes
sectors sectors
kilo kilo
meg meg

View File

@ -14,6 +14,7 @@
disable-unlink) disable-unlink)
(import (chezscheme) (import (chezscheme)
(disk-units)
(fmt fmt) (fmt fmt)
(srfi s8 receive) (srfi s8 receive)
(only (srfi s1 lists) span)) (only (srfi s1 lists) span))
@ -94,10 +95,15 @@
(with-temp-file-containing (rest ...) (with-temp-file-containing (rest ...)
b1 b2 ...)))))) b1 b2 ...))))))
(define (safe-to-bytes maybe-size)
(if (disk-size? maybe-size)
(to-bytes maybe-size)
maybe-size))
(define (with-temp-file-sized-thunk filename size fn) (define (with-temp-file-sized-thunk filename size fn)
(with-temp-file-thunk filename (with-temp-file-thunk filename
(lambda (path) (lambda (path)
(system (fmt #f "fallocate -l " (wrt size) " " path)) (system (fmt #f "fallocate -l " (wrt (safe-to-bytes size)) " " path))
(fn path)))) (fn path))))
(define-syntax with-temp-file-sized (define-syntax with-temp-file-sized