From da0e1aa69defa7cbc87209966c751918f523f1fb Mon Sep 17 00:00:00 2001 From: Piotr Szarmanski Date: Sat, 5 Aug 2023 22:57:30 +0200 Subject: Encoder refactor, new tests and proper non-file stream handling --- tests/common.lisp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/common.lisp') diff --git a/tests/common.lisp b/tests/common.lisp index 99a85c9..7a9309f 100644 --- a/tests/common.lisp +++ b/tests/common.lisp @@ -21,3 +21,18 @@ (defmacro make-octet-array-with-loop (loop) `(let ((seq ,loop)) (make-array (length seq) :element-type '(unsigned-byte 8) :initial-contents seq) )) + +(defun make-temporary-dir () + (let* ((tmpdir (uiop:temporary-directory)) + (tmp-tmpdir (make-pathname :directory (serapeum:append1 + (pathname-directory tmpdir) + (ironclad:byte-array-to-hex-string (ironclad:random-data 10))) + :defaults tmpdir))) + (ensure-directories-exist tmp-tmpdir) + tmp-tmpdir)) + +(defmacro with-temporary-dir (sym &body expr) + `(let ((,sym (make-temporary-dir))) + (unwind-protect + (progn ,@expr) + (uiop:delete-directory-tree ,sym :validate t)))) -- cgit v1.2.3