~ chicken-core (master) /tests/test-create-temporary-file.scm
Trap1(import (chicken file)2 (chicken pathname)3 (chicken platform)4 (chicken process-context))56;; Skip this test on Windows altogether, regardless of Windows variant7(when (eq? (software-type) 'windows)8 (print "Skipping test-create-temporary-file.scm due to problematic unsetenv behaviour on Windows")9 (exit 0))1011(define (with-environment-variable var val thunk)12 (let ((old-val (get-environment-variable var)))13 (set-environment-variable! var val)14 (thunk)15 (if old-val16 (set-environment-variable! var old-val)17 (unset-environment-variable! var))))1819(let ((tmp (create-temporary-file)))20 (delete-file tmp)21 (assert (pathname-directory tmp)))2223;; Assert that changes to the environment variables used by24;; create-temporary-file and create-temporary-directory get used (see25;; https://bugs.call-cc.org/ticket/1830).26;;27;; Here the use of "" as value of TMPDIR is because28;; (pathname-directory (make-pathname "" filename)) => #f29(with-environment-variable "TMPDIR" ""30 (lambda ()31 (let ((tmp (create-temporary-file)))32 (delete-file tmp)33 (assert (not (pathname-directory tmp))))))3435(with-environment-variable "TMPDIR" ""36 (lambda ()37 (let ((tmp (create-temporary-directory)))38 (delete-directory tmp)39 (assert (not (pathname-directory tmp))))))