Hi, Please see the commit message for more information.
All the best. Mario -- https://parenteses.org/mario
>From 0d38d2f6a859b59a2e69626cd4375eae17b3ae36 Mon Sep 17 00:00:00 2001 From: Mario Domenech Goulart <[email protected]> Date: Sun, 30 Nov 2025 15:16:11 +0100 Subject: [PATCH] Re-add tests/test-create-temporary-file.scm test-create-temporary-file.scm was removed in 860f8d764457b8 (presumably because it on the way to test C6 on Windows). Re-add the tests, but explicitly disable them on all Windows variants. The disablement is now done in the Scheme code, as runtests.bat doesn't exist in C6. --- distribution/manifest | 1 + tests/runtests.sh | 3 +++ tests/test-create-temporary-file.scm | 39 ++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/test-create-temporary-file.scm diff --git a/distribution/manifest b/distribution/manifest index dc5b7b2b..785b5d1f 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -216,6 +216,7 @@ tests/specialization-test-1.scm tests/specialization-test-2.scm tests/specialization-test-2.types tests/specialization.expected +tests/test-create-temporary-file.scm tests/test-irregex.scm tests/re-tests.txt tests/lolevel-tests.scm diff --git a/tests/runtests.sh b/tests/runtests.sh index 7753ae1f..8b4b93ea 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -439,6 +439,9 @@ $interpret -s file-access-tests.scm echo "======================================== find-files tests ..." $interpret -bnq test-find-files.scm +echo "======================================== create-temporary-file tests ..." +$interpret -bnq test-create-temporary-file.scm + echo "======================================== record-renaming tests ..." $interpret -bnq record-rename-test.scm diff --git a/tests/test-create-temporary-file.scm b/tests/test-create-temporary-file.scm new file mode 100644 index 00000000..d60394b3 --- /dev/null +++ b/tests/test-create-temporary-file.scm @@ -0,0 +1,39 @@ +(import (chicken file) + (chicken pathname) + (chicken platform) + (chicken process-context)) + +;; Skip this test on Windows altogether, regardless of Windows variant +(when (eq? (software-type) 'windows) + (print "Skipping test-create-temporary-file.scm due to problematic unsetenv behaviour on Windows") + (exit 0)) + +(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)))))) -- 2.47.3
