[functional-tests] factor out temp-file library
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
(functional-tests)
|
(functional-tests)
|
||||||
(cache-xml)
|
(cache-xml)
|
||||||
(fmt fmt)
|
(fmt fmt)
|
||||||
|
(temp-file)
|
||||||
(srfi s8 receive))
|
(srfi s8 receive))
|
||||||
|
|
||||||
(define-tool cache-check)
|
(define-tool cache-check)
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
(export
|
(export
|
||||||
info
|
info
|
||||||
|
|
||||||
temp-file
|
|
||||||
temp-file-containing
|
|
||||||
slurp-file
|
slurp-file
|
||||||
|
|
||||||
run
|
run
|
||||||
@ -34,6 +32,7 @@
|
|||||||
(chezscheme)
|
(chezscheme)
|
||||||
(fmt fmt)
|
(fmt fmt)
|
||||||
(list-utils)
|
(list-utils)
|
||||||
|
(temp-file)
|
||||||
(thin-xml)
|
(thin-xml)
|
||||||
(utils)
|
(utils)
|
||||||
(srfi s8 receive)
|
(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-file path)
|
||||||
(define (slurp)
|
(define (slurp)
|
||||||
(let ((output (get-string-all (current-input-port))))
|
(let ((output (get-string-all (current-input-port))))
|
||||||
|
26
functional-tests/temp-file.scm
Normal file
26
functional-tests/temp-file.scm
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
(library
|
||||||
|
(temp-file)
|
||||||
|
|
||||||
|
(export
|
||||||
|
temp-file
|
||||||
|
temp-file-containing)
|
||||||
|
|
||||||
|
(import (rnrs)
|
||||||
|
(fmt fmt))
|
||||||
|
|
||||||
|
(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))
|
||||||
|
|
||||||
|
)
|
@ -7,6 +7,7 @@
|
|||||||
(chezscheme)
|
(chezscheme)
|
||||||
(fmt fmt)
|
(fmt fmt)
|
||||||
(functional-tests)
|
(functional-tests)
|
||||||
|
(temp-file)
|
||||||
(thin-xml)
|
(thin-xml)
|
||||||
(srfi s8 receive)
|
(srfi s8 receive)
|
||||||
(only (srfi s1 lists) drop-while))
|
(only (srfi s1 lists) drop-while))
|
||||||
|
Reference in New Issue
Block a user