comparison scripts/testfun/runtests.m @ 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 516bb87ea72e
children dcf8922b724b
comparison
equal deleted inserted replaced
21569:6a550a383bf1 21570:faa23d2161f8
36 if (nargin == 0) 36 if (nargin == 0)
37 dirs = ostrsplit (path (), pathsep ()); 37 dirs = ostrsplit (path (), pathsep ());
38 do_class_dirs = true; 38 do_class_dirs = true;
39 elseif (nargin == 1) 39 elseif (nargin == 1)
40 dirs = {canonicalize_file_name(directory)}; 40 dirs = {canonicalize_file_name(directory)};
41 if (isempty (dirs{1})) 41 if (isempty (dirs{1}) || ! isdir (dirs{1}))
42 ## Search for directory name in path 42 ## Search for directory name in path
43 if (directory(end) == '/' || directory(end) == '\') 43 if (directory(end) == '/' || directory(end) == '\')
44 directory(end) = []; 44 directory(end) = [];
45 endif 45 endif
46 fullname = dir_in_loadpath (directory); 46 fullname = dir_in_loadpath (directory);
73 || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) 73 || (length (f) > 3 && strcmpi (f((end-2):end), ".cc")))
74 ff = fullfile (directory, f); 74 ff = fullfile (directory, f);
75 if (has_tests (ff)) 75 if (has_tests (ff))
76 print_test_file_name (f); 76 print_test_file_name (f);
77 [p, n, xf, sk] = test (ff, "quiet"); 77 [p, n, xf, sk] = test (ff, "quiet");
78 print_pass_fail (n, p); 78 print_pass_fail (n, p, xf);
79 fflush (stdout); 79 fflush (stdout);
80 elseif (has_functions (ff)) 80 elseif (has_functions (ff))
81 no_tests(end+1) = f; 81 no_tests(end+1) = f;
82 endif 82 endif
83 elseif (f(1) == "@") 83 elseif (f(1) == "@")
130 else 130 else
131 error ("runtests: fopen failed: %s", f); 131 error ("runtests: fopen failed: %s", f);
132 endif 132 endif
133 endfunction 133 endfunction
134 134
135 function print_pass_fail (n, p) 135 function print_pass_fail (n, p, xf)
136 if (n > 0) 136 if (n > 0)
137 printf (" PASS %4d/%-4d", p, n); 137 printf (" PASS %4d/%-4d", p, n);
138 nfail = n - p; 138 nfail = n - p;
139 if (nfail > 0) 139 if (nfail > 0)
140 printf (" FAIL %d", nfail); 140 if (nfail != xf)
141 printf (" FAIL %d", nfail - xf);
142 else
143 printf (" XFAIL %d", xf);
144 endif
141 endif 145 endif
142 endif 146 endif
143 puts ("\n"); 147 puts ("\n");
144 endfunction 148 endfunction
145 149