[functional-tests] factor out temp-file library

This commit is contained in:
Joe Thornber
2017-08-23 10:48:33 +01:00
parent 1cc2ab62ae
commit e3053df850
4 changed files with 29 additions and 17 deletions

View File

@@ -4,8 +4,6 @@
(export
info
temp-file
temp-file-containing
slurp-file
run
@@ -34,6 +32,7 @@
(chezscheme)
(fmt fmt)
(list-utils)
(temp-file)
(thin-xml)
(utils)
(srfi s8 receive)
@@ -62,21 +61,6 @@
;;;--------------------------------------------------------------------
(define temp-file
(let ((counter 0))
(lambda ()
(let loop ()
(let ((path (fmt #f (cat (dsp "/tmp/thinp-functional-tests-")
(pad-char #\0 (pad/left 4 (num counter)))))))
(set! counter (+ counter 1))
(if (file-exists? path) (loop) path))))))
;; Creates a temporary file with the specified contents.
(define (temp-file-containing contents)
(let ((path (temp-file)))
(with-output-to-file path (lambda () (put-string (current-output-port) contents)))
path))
(define (slurp-file path)
(define (slurp)
(let ((output (get-string-all (current-input-port))))