# HG changeset patch # User Rik # Date 1375728238 25200 # Node ID fa724bdd52d08c8890c7faba305f28a6e2278863 # Parent 4e9ff411d0fa6a76bc79bef66dc27d029e113eef __run_test_suite__.m: Recode regexps for performance. Don't search private '.' dirs. * scripts/testfun/__run_test_suite__.m: Recode regexps for performance. Don't search private '.' dirs. diff -r 4e9ff411d0fa -r fa724bdd52d0 scripts/testfun/__run_test_suite__.m --- a/scripts/testfun/__run_test_suite__.m Mon Aug 05 14:36:05 2013 -0400 +++ b/scripts/testfun/__run_test_suite__.m Mon Aug 05 11:43:58 2013 -0700 @@ -33,15 +33,15 @@ endif global files_with_no_tests = {}; global files_with_tests = {}; - ## FIXME -- these names don't really make sense if we are running - ## tests for an installed copy of Octave. + ## FIXME: These names don't really make sense if we are running + ## tests for an installed copy of Octave. global topsrcdir = fcnfiledir; global topbuilddir = testsdir; pso = page_screen_output (); warn_state = warning ("query", "quiet"); warning ("on", "quiet"); try - page_screen_output (0); + page_screen_output (false); warning ("off", "Octave:deprecated-function"); fid = fopen ("fntests.log", "wt"); if (fid < 0) @@ -92,9 +92,9 @@ endif ## Weed out deprecated and private functions - weed_idx = cellfun (@isempty, regexp (files_with_tests, '\bdeprecated\b|\bprivate\b', 'once')); + weed_idx = cellfun (@isempty, regexp (files_with_tests, '\|\', 'once')); files_with_tests = files_with_tests(weed_idx); - weed_idx = cellfun (@isempty, regexp (files_with_no_tests, '\bdeprecated\b|\bprivate\b', 'once')); + weed_idx = cellfun (@isempty, regexp (files_with_no_tests, '\|\', 'once')); files_with_no_tests = files_with_no_tests(weed_idx); report_files_with_no_tests (files_with_tests, files_with_no_tests, ".m"); @@ -103,7 +103,7 @@ puts ("these files (see the list in the file fntests.log).\n\n"); fprintf (fid, "\nFiles with no tests:\n\n%s", - list_in_columns (files_with_no_tests, 80)); + list_in_columns (files_with_no_tests, 80)); fclose (fid); page_screen_output (pso); @@ -133,16 +133,17 @@ function retval = has_functions (f) n = length (f); - if (n > 3 && strcmp (f((end-2):end), ".cc")) + if (n > 3 && strcmpi (f((end-2):end), ".cc")) fid = fopen (f); if (fid >= 0) str = fread (fid, "*char")'; fclose (fid); - retval = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD)\b', 'lineanchors')); + retval = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD)\>', + 'lineanchors', 'once')); else error ("fopen failed: %s", f); endif - elseif (n > 2 && strcmp (f((end-1):end), ".m")) + elseif (n > 2 && strcmpi (f((end-1):end), ".m")) retval = true; else retval = false; @@ -154,18 +155,8 @@ if (fid >= 0) str = fread (fid, "*char")'; fclose (fid); - retval = ! isempty (regexp (str, '^%!(assert|error|fail|test|warning)', "lineanchors")); - else - error ("fopen failed: %s", f); - endif -endfunction - -function retval = has_demos (f) - fid = fopen (f); - if (fid >= 0) - str = fread (fid, "*char")'; - fclose (fid); - retval = ! isempty (regexp (str, '^%!demo', "lineanchors")); + retval = ! isempty (regexp (str, '^%!(assert|error|fail|test|warning)', + 'lineanchors', 'once')); else error ("fopen failed: %s", f); endif @@ -179,9 +170,7 @@ for i = 1:length (lst) nm = lst(i).name; if (lst(i).isdir - && ! strcmp (nm, ".") && ! strcmp (nm, "..") - && ! strcmp (nm, "private") && nm(1) != "@" - && ! strcmp (nm, "CVS")) + && nm(1) != "." && ! strcmp (nm, "private") && nm(1) != "@") [p, n, xf, sk] = run_test_dir (fid, [d, filesep, nm]); dp += p; dn += n; @@ -194,7 +183,7 @@ chdir (d); for i = 1:length (lst) nm = lst(i).name; - if (length (nm) > 4 && strcmp (nm((end-3):end), ".tst")) + if (length (nm) > 4 && strcmpi (nm((end-3):end), ".tst")) p = n = xf = sk = 0; ffnm = fullfile (d, nm); if (has_tests (ffnm)) @@ -202,8 +191,6 @@ [p, n, xf, sk] = test (nm, "quiet", fid); print_pass_fail (n, p); files_with_tests(end+1) = ffnm; - ##elseif (has_demos (ffnm)) - ## files_with_tests(end+1) = ffnm; else files_with_no_tests(end+1) = ffnm; endif @@ -227,8 +214,7 @@ dp = dn = dxf = dsk = 0; for i = 1:length (lst) nm = lst(i).name; - if (lst(i).isdir && ! strcmp (nm, ".") && ! strcmp (nm, "..") - && ! strcmp (nm, "CVS")) + if (lst(i).isdir && nm(1) != ".") [p, n, xf, sk] = run_test_script (fid, [d, filesep, nm]); dp += p; dn += n; @@ -243,12 +229,12 @@ continue endif f = fullfile (d, nm); - if ((length (nm) > 2 && strcmp (nm((end-1):end), ".m")) + if ((length (nm) > 2 && strcmpi (nm((end-1):end), ".m")) || (length (nm) > 4 - && (strcmp (nm((end-3):end), "-tst") - || strcmp (nm((end-3):end), ".tst")))) + && ( strcmpi (nm((end-3):end), "-tst") + || strcmpi (nm((end-3):end), ".tst")))) p = n = xf = 0; - ## Only run if it contains %!test, %!assert %!error or %!warning + ## Only run if it contains %!test, %!assert, %!error, %!fail, or %!warning if (has_tests (f)) tmp = strrep (f, [topsrcdir, filesep], ""); tmp = strrep (tmp, [topbuilddir, filesep], ""); @@ -260,8 +246,6 @@ dxf += xf; dsk += sk; files_with_tests(end+1) = f; - ##elseif (has_demos (f)) - ## files_with_tests(end+1) = f; else ## To reduce the list length, only mark .cc files that contain ## DEFUN definitions.