[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Close every file and port used in ports.test
From: |
Eli Zaretskii |
Subject: |
Re: Close every file and port used in ports.test |
Date: |
Wed, 02 Jul 2014 18:33:16 +0300 |
> From: address@hidden (Ludovic Courtès)
> Cc: Mark H Weaver <address@hidden>, address@hidden
> Date: Wed, 02 Jul 2014 11:53:05 +0200
>
> Eli Zaretskii <address@hidden> skribis:
>
> > Here's one more fallout from digging into ports.test failures on
> > Windows. After all the ports.test tests are completed, Guile reported
> > a fatal error because it couldn't delete the temporary file used by
> > these tests.
> >
> > It turns out 6 of the tests were not closing the file after they were
> > done with it. Windows doesn't allow to delete an open file (unless it
> > was opened in a very special manner, something the "normal" Posix
> > emulating functions like 'open' don't do).
> >
> > Here's the patch to fix that:
>
> Makes sense, please push.
Done.
Here are 2 more similar gotchas. They failed silently, so it took
more time to detect (files with strange names "T-*" kept being left in
the test directory).
OK to push?
--- test-suite/tests/posix.test~0 2012-12-20 01:30:30 +0200
+++ test-suite/tests/posix.test 2014-07-02 18:18:33 +0300
@@ -73,6 +73,7 @@
(str (string-copy template))
(port (mkstemp! str))
(result (not (string=? str template))))
+ (close-port port)
(delete-file str)
result)))
--- test-suite/tests/r6rs-files.test~0 2012-01-31 01:32:38 +0200
+++ test-suite/tests/r6rs-files.test 2014-07-02 18:30:33 +0300
@@ -24,7 +24,9 @@
(with-test-prefix "delete-file"
(pass-if "delete-file deletes file"
- (let ((filename (port-filename (mkstemp! "T-XXXXXX"))))
+ (let* ((port (mkstemp! "T-XXXXXX"))
+ (filename (port-filename port)))
+ (close-port port)
(delete-file filename)
(not (file-exists? filename))))