changeset 17457:a4f86f459744

rundemos.m, runtests.m: Include class directories in path (bug #40053) * rundemos.m, runtests.m: Recurse into class directories in the path when operating on the entire search path.
author Mike Miller <mtmiller@ieee.org>
date Sat, 21 Sep 2013 08:30:34 -0400
parents 2c2a6801cb57
children f0ecb52097ec
files scripts/testfun/rundemos.m scripts/testfun/runtests.m
diffstat 2 files changed, 36 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/testfun/rundemos.m	Sat Sep 21 07:33:49 2013 -0400
+++ b/scripts/testfun/rundemos.m	Sat Sep 21 08:30:34 2013 -0400
@@ -34,6 +34,7 @@
 
   if (nargin == 0)
     dirs = ostrsplit (path (), pathsep ());
+    do_class_dirs = true;
   elseif (nargin == 1)
     if (is_absolute_filename (directory))
       dirs = {directory};
@@ -50,21 +51,23 @@
         error ("rundemos: DIRECTORY argument must be a valid pathname");
       endif
     endif
+    do_class_dirs = false;
   else
     print_usage ();
   endif
 
   for i = 1:numel (dirs)
     d = dirs{i};
-    run_all_demos (d);
+    run_all_demos (d, do_class_dirs);
   endfor
 
 endfunction
 
-function run_all_demos (directory)
-  flist = readdir (directory);
+function run_all_demos (directory, do_class_dirs)
+  flist = dir (directory);
+  dirs = {};
   for i = 1:numel (flist)
-    f = flist{i};
+    f = flist(i).name;
     if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) ||
         (length (f) > 3 && strcmpi (f((end-2):end), ".cc")))
       f = fullfile (directory, f);
@@ -78,8 +81,19 @@
           input ("Press <enter> to continue: ", "s");
         endif
       endif
+    elseif (flist(i).isdir && f(1) == "@")
+      f = fullfile (directory, f);
+      dirs = {dirs{:}, f};
     endif
   endfor
+
+  ## Recurse into class directories since they are implied in the path
+  if (do_class_dirs)
+    for i = 1:numel (dirs)
+      d = dirs{i};
+      run_all_demos (d, false);
+    endfor
+  endif
 endfunction
 
 function retval = has_demos (f)
--- a/scripts/testfun/runtests.m	Sat Sep 21 07:33:49 2013 -0400
+++ b/scripts/testfun/runtests.m	Sat Sep 21 08:30:34 2013 -0400
@@ -34,6 +34,7 @@
 
   if (nargin == 0)
     dirs = ostrsplit (path (), pathsep ());
+    do_class_dirs = true;
   elseif (nargin == 1)
     if (is_absolute_filename (directory))
       dirs = {directory};
@@ -50,24 +51,26 @@
         error ("runtests: DIRECTORY argument must be a valid pathname");
       endif
     endif
+    do_class_dirs = false;
   else
     print_usage ();
   endif
 
   for i = 1:numel (dirs)
     d = dirs{i};
-    run_all_tests (d);
+    run_all_tests (d, do_class_dirs);
   endfor
 
 endfunction
 
-function run_all_tests (directory)
-  flist = readdir (directory);
+function run_all_tests (directory, do_class_dirs)
+  flist = dir (directory);
+  dirs = {};
   no_tests = {};
   printf ("Processing files in %s:\n\n", directory);
   fflush (stdout);
   for i = 1:numel (flist)
-    f = flist{i};
+    f = flist(i).name;
     if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) ||
         (length (f) > 3 && strcmpi (f((end-2):end), ".cc")))
       ff = fullfile (directory, f);
@@ -79,12 +82,23 @@
       elseif (has_functions (ff))
         no_tests{end+1} = f;
       endif
+    elseif (flist(i).isdir && f(1) == "@")
+      f = fullfile (directory, f);
+      dirs = {dirs{:}, f};
     endif
   endfor
   if (! isempty (no_tests))
     printf ("\nThe following files in %s have no tests:\n\n", directory);
     printf ("%s", list_in_columns (no_tests));
   endif
+
+  ## Recurse into class directories since they are implied in the path
+  if (do_class_dirs)
+    for i = 1:numel (dirs)
+      d = dirs{i};
+      run_all_tests (d, false);
+    endfor
+  endif
 endfunction
 
 function retval = has_functions (f)