# HG changeset patch # User Rik # Date 1459453619 25200 # Node ID faa23d2161f8ea5e6f98c40fe468e196ee83e673 # Parent 6a550a383bf1740a2dd9f0b6546c6cdff64d6206 Stricter input validation for rundemos, runtests. * rundemos.m: Check that input is definitely a directory. * runtests.m: Check that input is definitely a directory. Change output to distinguish between true FAIL tests and XFAIL tests. diff -r 6a550a383bf1 -r faa23d2161f8 scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m Thu Mar 31 08:57:06 2016 -0700 +++ b/scripts/testfun/rundemos.m Thu Mar 31 12:46:59 2016 -0700 @@ -38,7 +38,7 @@ do_class_dirs = true; elseif (nargin == 1) dirs = {canonicalize_file_name(directory)}; - if (isempty (dirs{1})) + if (isempty (dirs{1}) || ! isdir (dirs{1})) ## Search for directory name in path if (directory(end) == '/' || directory(end) == '\') directory(end) = []; diff -r 6a550a383bf1 -r faa23d2161f8 scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m Thu Mar 31 08:57:06 2016 -0700 +++ b/scripts/testfun/runtests.m Thu Mar 31 12:46:59 2016 -0700 @@ -38,7 +38,7 @@ do_class_dirs = true; elseif (nargin == 1) dirs = {canonicalize_file_name(directory)}; - if (isempty (dirs{1})) + if (isempty (dirs{1}) || ! isdir (dirs{1})) ## Search for directory name in path if (directory(end) == '/' || directory(end) == '\') directory(end) = []; @@ -75,7 +75,7 @@ if (has_tests (ff)) print_test_file_name (f); [p, n, xf, sk] = test (ff, "quiet"); - print_pass_fail (n, p); + print_pass_fail (n, p, xf); fflush (stdout); elseif (has_functions (ff)) no_tests(end+1) = f; @@ -132,12 +132,16 @@ endif endfunction -function print_pass_fail (n, p) +function print_pass_fail (n, p, xf) if (n > 0) printf (" PASS %4d/%-4d", p, n); nfail = n - p; if (nfail > 0) - printf (" FAIL %d", nfail); + if (nfail != xf) + printf (" FAIL %d", nfail - xf); + else + printf (" XFAIL %d", xf); + endif endif endif puts ("\n");