diff options
author | Piotr Szarmanski | 2023-08-05 22:57:30 +0200 |
---|---|---|
committer | Piotr Szarmanski | 2023-08-05 22:57:30 +0200 |
commit | da0e1aa69defa7cbc87209966c751918f523f1fb (patch) | |
tree | ba1796f8500d314d93e46874e910492bf83ff4a2 /tests/common.lisp | |
parent | a5e2232edc0415dc16643aaeaafe91bdb1d18b59 (diff) |
Encoder refactor, new tests and proper non-file stream handling
Diffstat (limited to 'tests/common.lisp')
-rw-r--r-- | tests/common.lisp | 15 |
1 files changed, 15 insertions, 0 deletions
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)))) |