summaryrefslogtreecommitdiff
path: root/tests/common.lisp
diff options
context:
space:
mode:
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))))