Mercurial > hg > octave-nkf
annotate test/fntests.m @ 14626:f947d2922feb stable rc-3-6-2-0
3.6.2-rc0 release candidate
* configure.ac (AC_INIT): Version is now 3.6.2-rc0.
(OCTAVE_RELEASE_DATE): Now 2012-05-11.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 11 May 2012 13:46:18 -0400 |
parents | 72c96de7a403 |
children | e257d7363133 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13833
diff
changeset
|
1 ## Copyright (C) 2005-2012 David Bateman |
7016 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
5590 | 19 clear all; |
20 | |
5840 | 21 global files_with_no_tests = {}; |
5845 | 22 global files_with_tests = {}; |
5590 | 23 global topsrcdir; |
6257 | 24 global topbuilddir; |
5590 | 25 |
26 currdir = canonicalize_file_name ("."); | |
27 | |
28 if (nargin == 1) | |
5781 | 29 xdir = argv(){1}; |
5590 | 30 else |
31 xdir = "."; | |
32 endif | |
33 | |
34 srcdir = canonicalize_file_name (xdir); | |
35 topsrcdir = canonicalize_file_name (fullfile (xdir, "..")); | |
6257 | 36 topbuilddir = canonicalize_file_name (fullfile (currdir, "..")); |
5590 | 37 |
38 if (strcmp (currdir, srcdir)) | |
39 testdirs = {srcdir}; | |
40 else | |
41 testdirs = {currdir, srcdir}; | |
42 endif | |
43 | |
44 src_tree = canonicalize_file_name (fullfile (topsrcdir, "src")); | |
6257 | 45 liboctave_tree = canonicalize_file_name (fullfile (topsrcdir, "liboctave")); |
5590 | 46 script_tree = canonicalize_file_name (fullfile (topsrcdir, "scripts")); |
6257 | 47 local_script_tree = canonicalize_file_name (fullfile (currdir, "../scripts")); |
48 | |
6162 | 49 fundirs = {src_tree, liboctave_tree, script_tree}; |
5590 | 50 |
6257 | 51 if (! strcmp (currdir, srcdir)) |
52 fundirs{end+1} = local_script_tree; | |
53 endif | |
54 | |
5836 | 55 function print_test_file_name (nm) |
56 filler = repmat (".", 1, 55-length (nm)); | |
57 printf (" %s %s", nm, filler); | |
58 endfunction | |
59 | |
60 function print_pass_fail (n, p) | |
61 if (n > 0) | |
62 printf (" PASS %4d/%-4d", p, n); | |
63 nfail = n - p; | |
64 if (nfail > 0) | |
65 printf (" FAIL %d", nfail); | |
66 endif | |
67 endif | |
7762 | 68 puts ("\n"); |
5836 | 69 endfunction |
70 | |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
71 function retval = has_functions (f) |
10220
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
72 n = length (f); |
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
73 if (n > 3 && strcmp (f((end-2):end), ".cc")) |
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
74 fid = fopen (f); |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
75 if (fid >= 0) |
10220
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
76 str = fread (fid, "*char")'; |
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
77 fclose (fid); |
12462
e4dbfe3019b1
Use PCRE regular expressions throughout Octave.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
78 retval = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD)\b', 'lineanchors')); |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
79 else |
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
80 error ("fopen failed: %s", f); |
10220
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
81 endif |
04f2b4d68eba
test/fntests.m (hasfunctions): assume .m files have functions
John W. Eaton <jwe@octave.org>
parents:
10112
diff
changeset
|
82 elseif (n > 2 && strcmp (f((end-1):end), ".m")) |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
83 retval = true; |
9742
9f8ff01abc65
.cc files are now included in the list of files requiring
Rik <rdrider0-list@yahoo.com>
parents:
9741
diff
changeset
|
84 else |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
85 retval = false; |
9742
9f8ff01abc65
.cc files are now included in the list of files requiring
Rik <rdrider0-list@yahoo.com>
parents:
9741
diff
changeset
|
86 endif |
9f8ff01abc65
.cc files are now included in the list of files requiring
Rik <rdrider0-list@yahoo.com>
parents:
9741
diff
changeset
|
87 endfunction |
9f8ff01abc65
.cc files are now included in the list of files requiring
Rik <rdrider0-list@yahoo.com>
parents:
9741
diff
changeset
|
88 |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
89 function retval = has_tests (f) |
5840 | 90 fid = fopen (f); |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
91 if (fid >= 0) |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8423
diff
changeset
|
92 str = fread (fid, "*char")'; |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8423
diff
changeset
|
93 fclose (fid); |
13069
48c94e21b57f
codesprint: recognize "fail" as a test in fntests.m
John W. Eaton <jwe@octave.org>
parents:
13049
diff
changeset
|
94 retval = ! isempty (regexp (str, '^%!(assert|error|fail|test|warning)', "lineanchors")); |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
95 else |
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
96 error ("fopen failed: %s", f); |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8423
diff
changeset
|
97 endif |
5840 | 98 endfunction |
99 | |
12589
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
100 function retval = has_demos (f) |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
101 fid = fopen (f); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
102 if (fid >= 0) |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
103 str = fread (fid, "*char")'; |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
104 fclose (fid); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
105 retval = ! isempty (regexp (str, '^%!demo', "lineanchors")); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
106 else |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
107 error ("fopen failed: %s", f); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
108 endif |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
109 endfunction |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
110 |
7243 | 111 function [dp, dn, dxf, dsk] = run_test_dir (fid, d); |
5845 | 112 global files_with_tests; |
5840 | 113 global files_with_no_tests; |
5836 | 114 lst = dir (d); |
7243 | 115 dp = dn = dxf = dsk = 0; |
5836 | 116 for i = 1:length (lst) |
5590 | 117 nm = lst(i).name; |
13192
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
118 if (lst(i).isdir |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
119 && ! strcmp (nm, ".") && ! strcmp (nm, "..") |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
120 && ! strcmp (nm, "private") && nm(1) != "@" |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
121 && ! strcmp (nm, "CVS")) |
13833
0a28c49cb477
Format test suite output correctly on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13192
diff
changeset
|
122 [p, n, xf, sk] = run_test_dir (fid, [d, filesep, nm]); |
5836 | 123 dp += p; |
5590 | 124 dn += n; |
6730 | 125 dxf += xf; |
7243 | 126 dsk += sk; |
5590 | 127 endif |
128 endfor | |
13192
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
129 saved_dir = pwd (); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
130 unwind_protect |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
131 chdir (d); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
132 for i = 1:length (lst) |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
133 nm = lst(i).name; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
134 if (length (nm) > 5 && strcmp (nm(1:5), "test_") |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
135 && strcmp (nm((end-1):end), ".m")) |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
136 p = n = xf = sk = 0; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
137 ffnm = fullfile (d, nm); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
138 if (has_tests (ffnm)) |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
139 print_test_file_name (nm); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
140 [p, n, xf, sk] = test (nm(1:(end-2)), "quiet", fid); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
141 print_pass_fail (n, p); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
142 files_with_tests(end+1) = ffnm; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
143 ##elseif (has_demos (ffnm)) |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
144 ## files_with_tests(end+1) = ffnm; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
145 else |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
146 files_with_no_tests(end+1) = ffnm; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
147 endif |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
148 dp += p; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
149 dn += n; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
150 dxf += xf; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
151 dsk += sk; |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
152 endif |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
153 endfor |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
154 unwind_protect_cleanup |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
155 chdir (saved_dir); |
968e89b45bbf
move tests for classes into subdirectories
John W. Eaton <jwe@octave.org>
parents:
13069
diff
changeset
|
156 end_unwind_protect |
5590 | 157 endfunction |
158 | |
7243 | 159 function [dp, dn, dxf, dsk] = run_test_script (fid, d); |
5845 | 160 global files_with_tests; |
5840 | 161 global files_with_no_tests; |
5781 | 162 global topsrcdir; |
6257 | 163 global topbuilddir; |
5836 | 164 lst = dir (d); |
7243 | 165 dp = dn = dxf = dsk = 0; |
5836 | 166 for i = 1:length (lst) |
5590 | 167 nm = lst(i).name; |
5836 | 168 if (lst(i).isdir && ! strcmp (nm, ".") && ! strcmp (nm, "..") |
11227
84846912f3c1
test/fntests.m: run tests for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
11054
diff
changeset
|
169 && ! strcmp (nm, "CVS")) |
13833
0a28c49cb477
Format test suite output correctly on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13192
diff
changeset
|
170 [p, n, xf, sk] = run_test_script (fid, [d, filesep, nm]); |
5590 | 171 dp += p; |
172 dn += n; | |
6730 | 173 dxf += xf; |
7243 | 174 dsk += sk; |
5590 | 175 endif |
176 endfor | |
5836 | 177 for i = 1:length (lst) |
5590 | 178 nm = lst(i).name; |
10112
fddfebeeb33a
Run tests in all *.cc files.
David Grundberg <davidg@cs.umu.se>
parents:
10026
diff
changeset
|
179 ## Ignore hidden files |
fddfebeeb33a
Run tests in all *.cc files.
David Grundberg <davidg@cs.umu.se>
parents:
10026
diff
changeset
|
180 if (nm(1) == '.') |
fddfebeeb33a
Run tests in all *.cc files.
David Grundberg <davidg@cs.umu.se>
parents:
10026
diff
changeset
|
181 continue |
fddfebeeb33a
Run tests in all *.cc files.
David Grundberg <davidg@cs.umu.se>
parents:
10026
diff
changeset
|
182 endif |
9742
9f8ff01abc65
.cc files are now included in the list of files requiring
Rik <rdrider0-list@yahoo.com>
parents:
9741
diff
changeset
|
183 f = fullfile (d, nm); |
9f8ff01abc65
.cc files are now included in the list of files requiring
Rik <rdrider0-list@yahoo.com>
parents:
9741
diff
changeset
|
184 if ((length (nm) > 2 && strcmp (nm((end-1):end), ".m")) || |
10112
fddfebeeb33a
Run tests in all *.cc files.
David Grundberg <davidg@cs.umu.se>
parents:
10026
diff
changeset
|
185 (length (nm) > 3 && strcmp (nm((end-2):end), ".cc"))) |
6730 | 186 p = n = xf = 0; |
5590 | 187 ## Only run if it contains %!test, %!assert %!error or %!warning |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
188 if (has_tests (f)) |
13833
0a28c49cb477
Format test suite output correctly on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13192
diff
changeset
|
189 tmp = strrep (f, [topsrcdir, filesep], ""); |
0a28c49cb477
Format test suite output correctly on Win32.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13192
diff
changeset
|
190 tmp = strrep (tmp, [topbuilddir, filesep], ["..", filesep]); |
11033
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
191 print_test_file_name (tmp); |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
192 [p, n, xf, sk] = test (f, "quiet", fid); |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
193 print_pass_fail (n, p); |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
194 dp += p; |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
195 dn += n; |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
196 dxf += xf; |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
197 dsk += sk; |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
198 files_with_tests(end+1) = f; |
13043
098c8e696236
fntests.m: No longer count file with demos as being tested
Rik <octave@nomad.inbox5.com>
parents:
12589
diff
changeset
|
199 ##elseif (has_demos (f)) |
098c8e696236
fntests.m: No longer count file with demos as being tested
Rik <octave@nomad.inbox5.com>
parents:
12589
diff
changeset
|
200 ## files_with_tests(end+1) = f; |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
11019
diff
changeset
|
201 elseif (has_functions (f)) |
11033
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
202 ## To reduce the list length, only mark .cc files that contain |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
203 ## DEFUN definitions. |
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
204 files_with_no_tests(end+1) = f; |
5590 | 205 endif |
206 endif | |
207 endfor | |
5667 | 208 ## printf("%s%s -> passes %d of %d tests\n", ident, d, dp, dn); |
5590 | 209 endfunction |
210 | |
5836 | 211 function printf_assert (varargin) |
5590 | 212 global _assert_printf; |
5836 | 213 _assert_printf = cat (2, _assert_printf, sprintf (varargin{:})); |
5590 | 214 endfunction |
215 | |
5836 | 216 function ret = prog_output_assert (str) |
5590 | 217 global _assert_printf; |
5836 | 218 if (isempty (_assert_printf)) |
219 ret = isempty (str); | |
5590 | 220 elseif (_assert_printf(end) == "\n") |
5836 | 221 ret = strcmp (_assert_printf(1:(end-1)), str); |
5590 | 222 else |
5836 | 223 ret = strcmp (_assert_printf, str); |
5590 | 224 endif |
225 _assert_printf = ""; | |
226 endfunction | |
227 | |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
228 function n = num_elts_matching_pattern (lst, pat) |
12589
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
229 n = sum (cellfun (@(x) !isempty (x), regexp (lst, pat, 'once'))); |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
230 endfunction |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
231 |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
232 function report_files_with_no_tests (with, without, typ) |
12589
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
233 pat = cstrcat ('\', typ, "$"); |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
234 n_with = num_elts_matching_pattern (with, pat); |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
235 n_without = num_elts_matching_pattern (without, pat); |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
236 n_tot = n_with + n_without; |
13049
b37d8e5aedf3
fntests.m: Remove statement about demos from "No Tests" message
Rik <octave@nomad.inbox5.com>
parents:
13043
diff
changeset
|
237 printf ("\n%d (of %d) %s files have no tests.\n", n_without, n_tot, typ); |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
238 endfunction |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
239 |
5836 | 240 pso = page_screen_output (); |
241 warn_state = warning ("query", "quiet"); | |
242 warning ("on", "quiet"); | |
5590 | 243 try |
5836 | 244 page_screen_output (0); |
11227
84846912f3c1
test/fntests.m: run tests for deprecated functions
John W. Eaton <jwe@octave.org>
parents:
11054
diff
changeset
|
245 warning ("off", "Octave:deprecated-functions"); |
5836 | 246 fid = fopen ("fntests.log", "wt"); |
5590 | 247 if (fid < 0) |
5836 | 248 error ("could not open fntests.log for writing"); |
5590 | 249 endif |
5836 | 250 test ("", "explain", fid); |
7243 | 251 dp = dn = dxf = dsk = 0; |
7762 | 252 puts ("\nIntegrated test scripts:\n\n"); |
5836 | 253 for i = 1:length (fundirs) |
7243 | 254 [p, n, xf, sk] = run_test_script (fid, fundirs{i}); |
5836 | 255 dp += p; |
256 dn += n; | |
6730 | 257 dxf += xf; |
7243 | 258 dsk += sk; |
5590 | 259 endfor |
7762 | 260 puts ("\nFixed test scripts:\n\n"); |
5836 | 261 for i = 1:length (testdirs) |
7243 | 262 [p, n, xf, sk] = run_test_dir (fid, testdirs{i}); |
5836 | 263 dp += p; |
264 dn += n; | |
6730 | 265 dxf += xf; |
7243 | 266 dsk += sk; |
5590 | 267 endfor |
5836 | 268 printf ("\nSummary:\n\n PASS %6d\n", dp); |
5667 | 269 nfail = dn - dp; |
270 printf (" FAIL %6d\n", nfail); | |
6730 | 271 if (dxf > 0) |
7291 | 272 if (dxf > 1) |
7300 | 273 t1 = "were"; |
274 t2 = "failures"; | |
7291 | 275 else |
276 t1 = "was"; | |
277 t2 = "failure"; | |
278 endif | |
279 printf ("\nThere %s %d expected %s (see fntests.log for details).\n", | |
11033
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
280 t1, dxf, t2); |
11054
3b8817c91e31
fntests.m: Break output text differently for better readability.
Rik <octave@nomad.inbox5.com>
parents:
11033
diff
changeset
|
281 puts ("\nExpected failures are known bugs. Please help improve Octave\n"); |
3b8817c91e31
fntests.m: Break output text differently for better readability.
Rik <octave@nomad.inbox5.com>
parents:
11033
diff
changeset
|
282 puts ("by contributing fixes for them.\n"); |
6730 | 283 endif |
7243 | 284 if (dsk > 0) |
9696
01a1fd9167e0
Fix typo directing users to the wrong log file
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
285 printf ("\nThere were %d skipped tests (see fntests.log for details).\n", dsk); |
11054
3b8817c91e31
fntests.m: Break output text differently for better readability.
Rik <octave@nomad.inbox5.com>
parents:
11033
diff
changeset
|
286 puts ("Skipped tests are features that are disabled in this version of Octave\n"); |
3b8817c91e31
fntests.m: Break output text differently for better readability.
Rik <octave@nomad.inbox5.com>
parents:
11033
diff
changeset
|
287 puts ("because the needed libraries were not present when Octave was built.\n"); |
7243 | 288 endif |
289 | |
12589
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
290 ## Weed out deprecated and private functions |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
291 weed_idx = cellfun (@isempty, regexp (files_with_tests, '\bdeprecated\b|\bprivate\b', 'once')); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
292 files_with_tests = files_with_tests(weed_idx); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
293 weed_idx = cellfun (@isempty, regexp (files_with_no_tests, '\bdeprecated\b|\bprivate\b', 'once')); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
294 files_with_no_tests = files_with_no_tests(weed_idx); |
890af1cf0a86
Remove deprecated and private functions from list of functions requiring tests.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
295 |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
296 report_files_with_no_tests (files_with_tests, files_with_no_tests, ".m"); |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
297 report_files_with_no_tests (files_with_tests, files_with_no_tests, ".cc"); |
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
298 |
9710
519e164dde1e
Fix typo of an extra space in instructions to user
Rik <rdrider0-list@yahoo.com>
parents:
9696
diff
changeset
|
299 puts ("\nPlease help improve Octave by contributing tests for\n"); |
10899
686e3bc432a2
fntests.m: Add extra newline for more readable output during make.
Rik <octave@nomad.inbox5.com>
parents:
10220
diff
changeset
|
300 puts ("these files (see the list in the file fntests.log).\n\n"); |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
301 |
5840 | 302 fprintf (fid, "\nFiles with no tests:\n\n%s", |
11033
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
303 list_in_columns (files_with_no_tests, 80)); |
5836 | 304 fclose (fid); |
7645
734854f21c94
fntests.m: report number .m and .cc files without tests separately
John W. Eaton <jwe@octave.org>
parents:
7300
diff
changeset
|
305 |
5836 | 306 page_screen_output (pso); |
307 warning (warn_state.state, "quiet"); | |
5590 | 308 catch |
5836 | 309 page_screen_output (pso); |
310 warning (warn_state.state, "quiet"); | |
311 disp (lasterr ()); | |
5590 | 312 end_try_catch |