changeset 25521:a87b4dca2ce3

test.m: Warn if %!tests in file leak file descriptors. * test.m: Compare list of open file descriptors before and after running tests in file. Emit a warning (not error) if descriptors are leaked.
author Rik <rik@octave.org>
date Fri, 29 Jun 2018 09:44:35 -0700
parents 25d25966bda7
children 90c8325c14be
files scripts/testfun/test.m
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/testfun/test.m	Fri Jun 29 12:38:24 2018 -0400
+++ b/scripts/testfun/test.m	Fri Jun 29 09:44:35 2018 -0700
@@ -293,6 +293,9 @@
     disp ([__signal_file, __file]);
   endif
 
+  ## Track file descriptor leaks
+  __fid_list_orig = fopen ("all"); 
+
   ## Assume all tests will pass.
   __all_success = true;
 
@@ -732,6 +735,11 @@
   ## Clear any functions created during test run
   eval (__clearfcn, "");
 
+  ## Verify test file did not leak file descriptors
+  if (! isempty (setdiff (fopen ("all"), __fid_list_orig)))
+    warning ("test: file %s leaked file descriptors\n", __file);
+  endif
+
   if (nargout == 0)
     if (__tests || __xfail || __xbug || __xskip || __xrtskip)
       if (__xfail || __xbug)