# HG changeset patch # User Mike Miller # Date 1379766634 14400 # Node ID a4f86f459744d1bea2a38c5931d3028d2b0909cb # Parent 2c2a6801cb575009c3dc891a9a00cacf7fd9effb 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. diff -r 2c2a6801cb57 -r a4f86f459744 scripts/testfun/rundemos.m --- 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 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) diff -r 2c2a6801cb57 -r a4f86f459744 scripts/testfun/runtests.m --- 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)