diff --git a/tests/test-create-temporary-file.scm b/tests/test-create-temporary-file.scm index 67e664c3..45f743b4 100644 --- a/tests/test-create-temporary-file.scm +++ b/tests/test-create-temporary-file.scm @@ -1,6 +1,18 @@ (import (chicken file) + (chicken format) (chicken pathname) - (chicken process-context)) + (chicken process-context) + (chicken process-context posix) + (chicken time)) + +(define base-dir + (make-pathname (current-directory) + (sprintf "tmp-~a~a~a" + (current-seconds) + (current-process-id) + (current-process-milliseconds)))) + +(create-directory base-dir) (define (with-environment-variable var val thunk) (let ((old-val (get-environment-variable var))) @@ -17,17 +29,16 @@ ;; Assert that changes to the environment variables used by ;; create-temporary-file and create-temporary-directory get used (see ;; https://bugs.call-cc.org/ticket/1830). -;; -;; Here the use of "" as value of TMPDIR is because -;; (pathname-directory (make-pathname "" filename)) => #f -(with-environment-variable "TMPDIR" "" +(with-environment-variable "TMPDIR" base-dir (lambda () (let ((tmp (create-temporary-file))) (delete-file tmp) - (assert (not (pathname-directory tmp)))))) + (assert (string=? base-dir (pathname-directory tmp)))))) -(with-environment-variable "TMPDIR" "" +(with-environment-variable "TMPDIR" base-dir (lambda () (let ((tmp (create-temporary-directory))) (delete-directory tmp) - (assert (not (pathname-directory tmp)))))) + (assert (string=? base-dir (pathname-directory tmp)))))) + +(delete-directory base-dir #t)