Mercurial > octave
comparison scripts/testfun/runtests.m @ 21758:ffad2baa90f7
maint: Use newlines to make code more readable.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 20 May 2016 15:46:45 -0700 |
parents | 96518f623c91 |
children | bac0d6f07a3e |
comparison
equal
deleted
inserted
replaced
21757:c94fde6d7c27 | 21758:ffad2baa90f7 |
---|---|
60 endfor | 60 endfor |
61 | 61 |
62 endfunction | 62 endfunction |
63 | 63 |
64 function run_all_tests (directory, do_class_dirs) | 64 function run_all_tests (directory, do_class_dirs) |
65 | |
65 flist = readdir (directory); | 66 flist = readdir (directory); |
66 dirs = {}; | 67 dirs = {}; |
67 no_tests = {}; | 68 no_tests = {}; |
68 printf ("Processing files in %s:\n\n", directory); | 69 printf ("Processing files in %s:\n\n", directory); |
69 fflush (stdout); | 70 fflush (stdout); |
97 for i = 1:numel (dirs) | 98 for i = 1:numel (dirs) |
98 d = dirs{i}; | 99 d = dirs{i}; |
99 run_all_tests (d, false); | 100 run_all_tests (d, false); |
100 endfor | 101 endfor |
101 endif | 102 endif |
103 | |
102 endfunction | 104 endfunction |
103 | 105 |
104 function retval = has_functions (f) | 106 function retval = has_functions (f) |
107 | |
105 n = length (f); | 108 n = length (f); |
106 if (n > 3 && strcmpi (f((end-2):end), ".cc")) | 109 if (n > 3 && strcmpi (f((end-2):end), ".cc")) |
107 fid = fopen (f); | 110 fid = fopen (f); |
108 if (fid >= 0) | 111 if (fid < 0) |
109 str = fread (fid, "*char")'; | |
110 fclose (fid); | |
111 retval = ! isempty (regexp (str,'^(?:DEFUN|DEFUN_DLD|DEFUNX)\>', | |
112 'lineanchors', 'once')); | |
113 else | |
114 error ("runtests: fopen failed: %s", f); | 112 error ("runtests: fopen failed: %s", f); |
115 endif | 113 endif |
114 str = fread (fid, "*char")'; | |
115 fclose (fid); | |
116 retval = ! isempty (regexp (str,'^(?:DEFUN|DEFUN_DLD|DEFUNX)\>', | |
117 'lineanchors', 'once')); | |
116 elseif (n > 2 && strcmpi (f((end-1):end), ".m")) | 118 elseif (n > 2 && strcmpi (f((end-1):end), ".m")) |
117 retval = true; | 119 retval = true; |
118 else | 120 else |
119 retval = false; | 121 retval = false; |
120 endif | 122 endif |
123 | |
121 endfunction | 124 endfunction |
122 | 125 |
123 function retval = has_tests (f) | 126 function retval = has_tests (f) |
127 | |
124 fid = fopen (f); | 128 fid = fopen (f); |
125 if (fid >= 0) | 129 if (fid < 0) |
126 str = fread (fid, "*char").'; | |
127 fclose (fid); | |
128 retval = ! isempty (regexp (str, '^%!(?:test|xtest|assert|error|warning)', | |
129 'lineanchors', 'once')); | |
130 else | |
131 error ("runtests: fopen failed: %s", f); | 130 error ("runtests: fopen failed: %s", f); |
132 endif | 131 endif |
132 | |
133 str = fread (fid, "*char").'; | |
134 fclose (fid); | |
135 retval = ! isempty (regexp (str, '^%!(?:test|xtest|assert|error|warning)', | |
136 'lineanchors', 'once')); | |
137 | |
133 endfunction | 138 endfunction |
134 | 139 |
135 function print_pass_fail (n, p, xf) | 140 function print_pass_fail (n, p, xf) |
141 | |
136 if (n > 0) | 142 if (n > 0) |
137 printf (" PASS %4d/%-4d", p, n); | 143 printf (" PASS %4d/%-4d", p, n); |
138 nfail = n - p; | 144 nfail = n - p; |
139 if (nfail > 0) | 145 if (nfail > 0) |
140 if (nfail != xf) | 146 if (nfail != xf) |
143 printf (" XFAIL %d", xf); | 149 printf (" XFAIL %d", xf); |
144 endif | 150 endif |
145 endif | 151 endif |
146 endif | 152 endif |
147 puts ("\n"); | 153 puts ("\n"); |
154 | |
148 endfunction | 155 endfunction |
149 | 156 |
150 function print_test_file_name (nm) | 157 function print_test_file_name (nm) |
151 filler = repmat (".", 1, 55-length (nm)); | 158 filler = repmat (".", 1, 55-length (nm)); |
152 printf (" %s %s", nm, filler); | 159 printf (" %s %s", nm, filler); |