unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Close every file and port used in ports.test
@ 2014-06-30 15:04 Eli Zaretskii
  2014-07-02  9:53 ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2014-06-30 15:04 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Mark H Weaver, guile-devel

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)))))))
 
 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Close every file and port used in ports.test
  2014-06-30 15:04 Close every file and port used in ports.test Eli Zaretskii
@ 2014-07-02  9:53 ` Ludovic Courtès
  2014-07-02 15:33   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2014-07-02  9:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Mark H Weaver, guile-devel

Eli Zaretskii <eliz@gnu.org> 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.

Thanks,
Ludo’.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Close every file and port used in ports.test
  2014-07-02  9:53 ` Ludovic Courtès
@ 2014-07-02 15:33   ` Eli Zaretskii
  2014-07-02 17:38     ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2014-07-02 15:33 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: mhw, guile-devel

> From: ludo@gnu.org (Ludovic Courtès)
> Cc: Mark H Weaver <mhw@netris.org>,  guile-devel@gnu.org
> Date: Wed, 02 Jul 2014 11:53:05 +0200
> 
> Eli Zaretskii <eliz@gnu.org> 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))))
 




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Close every file and port used in ports.test
  2014-07-02 15:33   ` Eli Zaretskii
@ 2014-07-02 17:38     ` Ludovic Courtès
  2014-07-02 18:23       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2014-07-02 17:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: mhw, guile-devel

Eli Zaretskii <eliz@gnu.org> skribis:

> 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?

Sure.

Ludo'.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Close every file and port used in ports.test
  2014-07-02 17:38     ` Ludovic Courtès
@ 2014-07-02 18:23       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2014-07-02 18:23 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: mhw, guile-devel

> From: ludo@gnu.org (Ludovic Courtès)
> Cc: mhw@netris.org,  guile-devel@gnu.org
> Date: Wed, 02 Jul 2014 19:38:51 +0200
> 
> Eli Zaretskii <eliz@gnu.org> skribis:
> 
> > 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?
> 
> Sure.

Done.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-02 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30 15:04 Close every file and port used in ports.test Eli Zaretskii
2014-07-02  9:53 ` Ludovic Courtès
2014-07-02 15:33   ` Eli Zaretskii
2014-07-02 17:38     ` Ludovic Courtès
2014-07-02 18:23       ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).