~ chicken-core (chicken-5) /tests/test-create-temporary-file.scm
Trap1(import (chicken file)2 (chicken pathname)3 (chicken process-context))45(define (with-environment-variable var val thunk)6 (let ((old-val (get-environment-variable var)))7 (set-environment-variable! var val)8 (thunk)9 (if old-val10 (set-environment-variable! var old-val)11 (unset-environment-variable! var))))1213(let ((tmp (create-temporary-file)))14 (delete-file tmp)15 (assert (pathname-directory tmp)))1617;; Assert that changes to the environment variables used by18;; create-temporary-file and create-temporary-directory get used (see19;; https://bugs.call-cc.org/ticket/1830).20;;21;; Here the use of "" as value of TMPDIR is because22;; (pathname-directory (make-pathname "" filename)) => #f23(with-environment-variable "TMPDIR" ""24 (lambda ()25 (let ((tmp (create-temporary-file)))26 (delete-file tmp)27 (assert (not (pathname-directory tmp))))))2829(with-environment-variable "TMPDIR" ""30 (lambda ()31 (let ((tmp (create-temporary-directory)))32 (delete-directory tmp)33 (assert (not (pathname-directory tmp))))))