summaryrefslogtreecommitdiff
path: root/tests/common.lisp
diff options
context:
space:
mode:
authorPiotr Szarmanski2023-08-05 22:57:30 +0200
committerPiotr Szarmanski2023-08-05 22:57:30 +0200
commitda0e1aa69defa7cbc87209966c751918f523f1fb (patch)
treeba1796f8500d314d93e46874e910492bf83ff4a2 /tests/common.lisp
parenta5e2232edc0415dc16643aaeaafe91bdb1d18b59 (diff)
Encoder refactor, new tests and proper non-file stream handling
Diffstat (limited to 'tests/common.lisp')
-rw-r--r--tests/common.lisp15
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))))