tests: improve with-temporary-file macro

This commit is contained in:
Daniel Kochmański 2016-11-20 12:16:26 +01:00
parent 17bce26704
commit cc70b9feab

View file

@ -127,11 +127,10 @@ as a second value."
(setf compiled-file (compile-file ,filename ,@compiler-args))))))
(values compiled-file output))))
(defmacro with-temporary-file ((var string) &body body)
(defmacro with-temporary-file ((var string &rest args) &body body)
(ext:with-unique-names (stream)
(ext:once-only (string)
`(let ((,var (ext:mkstemp "ecl-tests")))
(with-open-file (,stream ,var :direction :output)
(format ,stream ,string))
(multiple-value-prog1 (progn ,@body)
(delete-file ,var))))))
`(let ((,var (ext:mkstemp "ecl-tests")))
(with-open-file (,stream ,var :direction :output)
(format ,stream ,string ,@args))
(multiple-value-prog1 (progn ,@body)
(delete-file ,var)))))