changeset 21570:faa23d2161f8

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.
author Rik <rik@octave.org>
date Thu, 31 Mar 2016 12:46:59 -0700
parents 6a550a383bf1
children feac06371be1
files scripts/testfun/rundemos.m scripts/testfun/runtests.m
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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) = [];
--- 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");