[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Close every file and port used in ports.test
From: |
Eli Zaretskii |
Subject: |
Close every file and port used in ports.test |
Date: |
Mon, 30 Jun 2014 18:04:07 +0300 |
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:
--- test-suite/tests/ports.test~0 2014-02-15 01:00:34 +0200
+++ test-suite/tests/ports.test 2014-06-29 16:06:51 +0300
@@ -1246,9 +1247,10 @@
(with-test-prefix
"fdes->port"
(pass-if "fdes->ports finds port"
- (let ((port (open-file (test-file) "w")))
-
- (not (not (memq port (fdes->ports (port->fdes port))))))))
+ (let* ((port (open-file (test-file) "w"))
+ (res (not (not (memq port (fdes->ports (port->fdes port)))))))
+ (close-port port)
+ res)))
;;;
;;; seek
@@ -1265,7 +1267,9 @@
(let ((port (open-file (test-file) "r")))
(read-char port)
(seek port 2 SEEK_CUR)
- (eqv? #\d (read-char port))))
+ (let ((res (eqv? #\d (read-char port))))
+ (close-port port)
+ res)))
(pass-if "SEEK_SET"
(call-with-output-file (test-file)
@@ -1274,7 +1278,9 @@
(let ((port (open-file (test-file) "r")))
(read-char port)
(seek port 3 SEEK_SET)
- (eqv? #\d (read-char port))))
+ (let ((res (eqv? #\d (read-char port))))
+ (close-port port)
+ res)))
(pass-if "SEEK_END"
(call-with-output-file (test-file)
@@ -1283,7 +1289,9 @@
(let ((port (open-file (test-file) "r")))
(read-char port)
(seek port -2 SEEK_END)
- (eqv? #\d (read-char port))))))
+ (let ((res (eqv? #\d (read-char port))))
+ (close-port port)
+ res)))))
;;;
;;; truncate-file
@@ -1346,7 +1354,8 @@
(lambda (port)
(display "hello" port)))
(let ((port (open-file (test-file) "r+")))
- (truncate-file port 1))
+ (truncate-file port 1)
+ (close-port port))
(eqv? 1 (stat:size (stat (test-file)))))
(pass-if "shorten to current pos"
@@ -1355,7 +1364,8 @@
(display "hello" port)))
(let ((port (open-file (test-file) "r+")))
(read-char port)
- (truncate-file port))
+ (truncate-file port)
+ (close-port port))
(eqv? 1 (stat:size (stat (test-file)))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Close every file and port used in ports.test,
Eli Zaretskii <=