diff scripts/testfun/runtests.m @ 11024:fa56fd98c0c5

Remove requirement for PCRE in Octave. (Bug #31025)
author Rik <octave@nomad.inbox5.com>
date Sun, 26 Sep 2010 12:55:38 -0700
parents d1978e7364ad
children c9b0a75b02e8
line wrap: on
line diff
--- a/scripts/testfun/runtests.m	Sat Sep 25 17:17:51 2010 -0400
+++ b/scripts/testfun/runtests.m	Sun Sep 26 12:55:38 2010 -0700
@@ -17,7 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} rundtests (@var{directory})
+## @deftypefn {Function File} {} runtests (@var{directory})
+## Execute built-in tests for all function files in the specified directory.
 ## @end deftypefn
 
 ## Author: jwe
@@ -69,23 +70,19 @@
     endif
   endfor
   if (! isempty (no_tests))
-    printf ("\nThe following files in have no tests:\n\n", directory);
+    printf ("\nThe following files in %s have no tests:\n\n", directory);
     printf ("%s", list_in_columns (no_tests));
   endif
 endfunction
 
 function retval = has_tests (f)
-  retval = false;
   fid = fopen (f);
   if (fid >= 0)
-    while (! feof (fid))
-      ln = fgetl (fid);
-      if (! isempty (regexp (ln, "%!(assert|error|test)", "lineanchors")))
-        retval = true;
-        break;
-      endif
-    endwhile
+    str = fread (fid, "*char")';
     fclose (fid);
+    ## Avoid PCRE 'lineanchors' by searching for newline followed by PTN.
+    ## Equivalent to regexp ('^PTN','lineanchors')
+    retval = ! isempty (regexp (str, '[\r\n]\s*%!(test|assert|error|warning)', "once"));
   else
     error ("runtests: fopen failed: %s", f);
   endif