~ chicken-core (chicken-5) 1795d8cd150172967f7fcd4da2cc2edc6ec02a52
commit 1795d8cd150172967f7fcd4da2cc2edc6ec02a52 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Wed Jan 3 14:40:49 2024 +0100 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Wed Jan 3 14:40:49 2024 +0100 file missing diff --git a/tests/test-create-temporary-file.scm b/tests/test-create-temporary-file.scm new file mode 100644 index 00000000..67e664c3 --- /dev/null +++ b/tests/test-create-temporary-file.scm @@ -0,0 +1,33 @@ +(import (chicken file) + (chicken pathname) + (chicken process-context)) + +(define (with-environment-variable var val thunk) + (let ((old-val (get-environment-variable var))) + (set-environment-variable! var val) + (thunk) + (if old-val + (set-environment-variable! var old-val) + (unset-environment-variable! var)))) + +(let ((tmp (create-temporary-file))) + (delete-file tmp) + (assert (pathname-directory tmp))) + +;; 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" "" + (lambda () + (let ((tmp (create-temporary-file))) + (delete-file tmp) + (assert (not (pathname-directory tmp)))))) + +(with-environment-variable "TMPDIR" "" + (lambda () + (let ((tmp (create-temporary-directory))) + (delete-directory tmp) + (assert (not (pathname-directory tmp))))))Trap