annotate scripts/testfun/oruntests.m @ 27918:b442ec6dda5c

use centralized file for copyright info for individual contributors * COPYRIGHT.md: New file. * In most other files, use "Copyright (C) YYYY-YYYY The Octave Project Developers" instead of tracking individual names in separate source files. The motivation is to reduce the effort required to update the notices each year. Until now, the Octave source files contained copyright notices that list individual contributors. I adopted these file-scope copyright notices because that is what everyone was doing 30 years ago in the days before distributed version control systems. But now, with many contributors and modern version control systems, having these file-scope copyright notices causes trouble when we update copyright years or refactor code. Over time, the file-scope copyright notices may become outdated as new contributions are made or code is moved from one file to another. Sometimes people contribute significant patches but do not add a line claiming copyright. Other times, people add a copyright notice for their contribution but then a later refactoring moves part or all of their contribution to another file and the notice is not moved with the code. As a practical matter, moving such notices is difficult -- determining what parts are due to a particular contributor requires a time-consuming search through the project history. Even managing the yearly update of copyright years is problematic. We have some contributors who are no longer living. Should we update the copyright dates for their contributions when we release new versions? Probably not, but we do still want to claim copyright for the project as a whole. To minimize the difficulty of maintaining the copyright notices, I would like to change Octave's sources to use what is described here: https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html in the section "Maintaining centralized copyright notices": The centralized notice approach consolidates all copyright notices in a single location, usually a top-level file. This file should contain all of the copyright notices provided project contributors, unless the contribution was clearly insignificant. It may also credit -- without a copyright notice -- anyone who helped with the project but did not contribute code or other copyrighted material. This approach captures less information about contributions within individual files, recognizing that the DVCS is better equipped to record those details. As we mentioned before, it does have one disadvantage as compared to the file-scope approach: if a single file is separated from the distribution, the recipient won't see the contributors' copyright notices. But this can be easily remedied by including a single copyright notice in each file's header, pointing to the top-level file: Copyright YYYY-YYYY The Octave Project Developers See the COPYRIGHT file at the top-level directory of this distribution or at https://octave.org/COPYRIGHT.html. followed by the usual GPL copyright statement. For more background, see the discussion here: https://lists.gnu.org/archive/html/octave-maintainers/2020-01/msg00009.html Most files in the following directories have been skipped intentinally in this changeset: doc libgui/qterminal liboctave/external m4
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 15:38:17 -0500
parents 695bb9322a21
children 1891570abac8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27915
diff changeset
1 ## Copyright (C) 2010-2019 The Octave Project Developers
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27915
diff changeset
2 ##
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27915
diff changeset
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27915
diff changeset
4 ## or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27915
diff changeset
5 ##
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ##
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## This file is part of Octave.
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24483
diff changeset
9 ## Octave is free software: you can redistribute it and/or modify it
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24483
diff changeset
11 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## (at your option) any later version.
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ##
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ## Octave is distributed in the hope that it will be useful, but
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## GNU General Public License for more details.
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 ##
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## You should have received a copy of the GNU General Public License
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24483
diff changeset
21 ## <https://www.gnu.org/licenses/>.
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 ## -*- texinfo -*-
27115
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
24 ## @deftypefn {} {} oruntests ()
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
25 ## @deftypefnx {} {} oruntests (@var{directory})
19025
f27140dd13a6 doc: Update documentation for assert, rundemos, runtests.
Rik <rik@octave.org>
parents: 18110
diff changeset
26 ## Execute built-in tests for all m-files in the specified @var{directory}.
f27140dd13a6 doc: Update documentation for assert, rundemos, runtests.
Rik <rik@octave.org>
parents: 18110
diff changeset
27 ##
f27140dd13a6 doc: Update documentation for assert, rundemos, runtests.
Rik <rik@octave.org>
parents: 18110
diff changeset
28 ## Test blocks in any C++ source files (@file{*.cc}) will also be executed
f27140dd13a6 doc: Update documentation for assert, rundemos, runtests.
Rik <rik@octave.org>
parents: 18110
diff changeset
29 ## for use with dynamically linked oct-file functions.
17148
fa14aa77b514 Allow relative directory name for rundemos/runtests.
Rik <rik@octave.org>
parents: 16724
diff changeset
30 ##
20162
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19865
diff changeset
31 ## If no directory is specified, operate on all directories in Octave's search
2645f9ef8c88 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19865
diff changeset
32 ## path for functions.
19025
f27140dd13a6 doc: Update documentation for assert, rundemos, runtests.
Rik <rik@octave.org>
parents: 18110
diff changeset
33 ## @seealso{rundemos, test, path}
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 ## @end deftypefn
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
27115
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
36 function oruntests (directory)
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 if (nargin == 0)
16724
b7667fcb9fbc Substitute ostrsplit() for strsplit().
Ben Abbott <bpabbott@mac.com>
parents: 16403
diff changeset
39 dirs = ostrsplit (path (), pathsep ());
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
40 do_class_dirs = true;
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 elseif (nargin == 1)
18059
b675665ce328 Simplify directory testing code for rundemos, runtests.
Rik <rik@octave.org>
parents: 18054
diff changeset
42 dirs = {canonicalize_file_name(directory)};
25781
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25054
diff changeset
43 if (isempty (dirs{1}) || ! isfolder (dirs{1}))
18059
b675665ce328 Simplify directory testing code for rundemos, runtests.
Rik <rik@octave.org>
parents: 18054
diff changeset
44 ## Search for directory name in path
b675665ce328 Simplify directory testing code for rundemos, runtests.
Rik <rik@octave.org>
parents: 18054
diff changeset
45 if (directory(end) == '/' || directory(end) == '\')
b675665ce328 Simplify directory testing code for rundemos, runtests.
Rik <rik@octave.org>
parents: 18054
diff changeset
46 directory(end) = [];
17148
fa14aa77b514 Allow relative directory name for rundemos/runtests.
Rik <rik@octave.org>
parents: 16724
diff changeset
47 endif
18110
2217bc116aa9 maint: Dummy merge with gui-release, ignoring all recent backout merges
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 18105
diff changeset
48 fullname = dir_in_loadpath (directory);
18054
70e83c641b48 Accept a bare directory name for rundemos and runtests.
Rik <rik@octave.org>
parents: 18053
diff changeset
49 if (isempty (fullname))
27115
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
50 error ("oruntests: DIRECTORY argument must be a valid pathname");
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 endif
18054
70e83c641b48 Accept a bare directory name for rundemos and runtests.
Rik <rik@octave.org>
parents: 18053
diff changeset
52 dirs = {fullname};
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 endif
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
54 do_class_dirs = false;
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 else
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 print_usage ();
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 endif
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 for i = 1:numel (dirs)
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 d = dirs{i};
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
61 run_all_tests (d, do_class_dirs);
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 endfor
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 endfunction
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
66 function run_all_tests (directory, do_class_dirs)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
67
17459
f271fa40074d runtests.m, rundemos.m: Use readdir, rather than dir, for ~700X speed-up.
Rik <rik@octave.org>
parents: 17458
diff changeset
68 flist = readdir (directory);
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
69 dirs = {};
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 no_tests = {};
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
71 printf ("Processing files in %s:\n\n", directory);
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 fflush (stdout);
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 for i = 1:numel (flist)
17459
f271fa40074d runtests.m, rundemos.m: Use readdir, rather than dir, for ~700X speed-up.
Rik <rik@octave.org>
parents: 17458
diff changeset
74 f = flist{i};
19865
e9f89866074c maint: Cleanup some .m files to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
75 if ((length (f) > 2 && strcmpi (f((end-1):end), ".m"))
e9f89866074c maint: Cleanup some .m files to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
76 || (length (f) > 3 && strcmpi (f((end-2):end), ".cc")))
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 ff = fullfile (directory, f);
27915
695bb9322a21 oruntests.m: validate .m/.cc names are actually files before testing.
Rik <rik@octave.org>
parents: 27898
diff changeset
78 if (! isfile (ff))
695bb9322a21 oruntests.m: validate .m/.cc names are actually files before testing.
Rik <rik@octave.org>
parents: 27898
diff changeset
79 continue;
695bb9322a21 oruntests.m: validate .m/.cc names are actually files before testing.
Rik <rik@octave.org>
parents: 27898
diff changeset
80 endif
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 if (has_tests (ff))
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 print_test_file_name (f);
24480
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
83 [p, n, xf, xb, sk, rtsk, rgrs] = test (ff, "quiet");
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
84 print_pass_fail (p, n, xf, xb, sk, rtsk, rgrs);
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 fflush (stdout);
17456
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
86 elseif (has_functions (ff))
17459
f271fa40074d runtests.m, rundemos.m: Use readdir, rather than dir, for ~700X speed-up.
Rik <rik@octave.org>
parents: 17458
diff changeset
87 no_tests(end+1) = f;
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 endif
17459
f271fa40074d runtests.m, rundemos.m: Use readdir, rather than dir, for ~700X speed-up.
Rik <rik@octave.org>
parents: 17458
diff changeset
89 elseif (f(1) == "@")
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
90 f = fullfile (directory, f);
25781
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25054
diff changeset
91 if (isfolder (f))
17459
f271fa40074d runtests.m, rundemos.m: Use readdir, rather than dir, for ~700X speed-up.
Rik <rik@octave.org>
parents: 17458
diff changeset
92 dirs(end+1) = f;
f271fa40074d runtests.m, rundemos.m: Use readdir, rather than dir, for ~700X speed-up.
Rik <rik@octave.org>
parents: 17458
diff changeset
93 endif
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 endif
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 endfor
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 if (! isempty (no_tests))
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
97 printf ("\nThe following files in %s have no tests:\n\n", directory);
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
98 printf ("%s", list_in_columns (no_tests));
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 endif
17457
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
100
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
101 ## Recurse into class directories since they are implied in the path
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
102 if (do_class_dirs)
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
103 for i = 1:numel (dirs)
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
104 d = dirs{i};
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
105 run_all_tests (d, false);
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
106 endfor
a4f86f459744 rundemos.m, runtests.m: Include class directories in path (bug #40053)
Mike Miller <mtmiller@ieee.org>
parents: 17456
diff changeset
107 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
108
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 endfunction
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110
17456
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
111 function retval = has_functions (f)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
112
17456
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
113 n = length (f);
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
114 if (n > 3 && strcmpi (f((end-2):end), ".cc"))
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
115 fid = fopen (f);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
116 if (fid < 0)
27115
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
117 error ("oruntests: fopen failed: %s", f);
17456
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
118 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
119 str = fread (fid, "*char")';
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
120 fclose (fid);
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
121 retval = ! isempty (regexp (str,'^(?:DEFUN|DEFUN_DLD|DEFUNX)\>',
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
122 'lineanchors', 'once'));
17456
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
123 elseif (n > 2 && strcmpi (f((end-1):end), ".m"))
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
124 retval = true;
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
125 else
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
126 retval = false;
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
127 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
128
17456
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
129 endfunction
2c2a6801cb57 rundemos.m, runtests.m: Operate on .cc files (bug #40052)
Mike Miller <mtmiller@ieee.org>
parents: 17148
diff changeset
130
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 function retval = has_tests (f)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
132
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 fid = fopen (f);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
134 if (fid < 0)
27115
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
135 error ("oruntests: fopen failed: %s", f);
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
137
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
138 str = fread (fid, "*char").';
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
139 fclose (fid);
24480
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
140 retval = ! isempty (regexp (str,
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
141 '^%!(assert|error|fail|test|xtest|warning)',
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
142 'lineanchors', 'once'));
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
143
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144 endfunction
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145
24480
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
146 function print_pass_fail (p, n, xf, xb, sk, rtsk, rgrs)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
147
24480
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
148 if ((n + sk + rtsk + rgrs) > 0)
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
149 printf (" PASS %4d/%-4d", p, n);
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
150 nfail = n - p - xf - xb - rgrs;
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 if (nfail > 0)
24480
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
152 printf ("\n%71s %3d", "FAIL ", nfail);
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
153 endif
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
154 if (rgrs > 0)
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
155 printf ("\n%71s %3d", "REGRESSION", rgrs);
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
156 endif
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
157 if (xb > 0)
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
158 printf ("\n%71s %3d", "(reported bug) XFAIL", xb);
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
159 endif
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
160 if (xf > 0)
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
161 printf ("\n%71s %3d", "(expected failure) XFAIL", xf);
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 endif
24483
dac2ad033c43 use same wording and order for individual test results and summary
John W. Eaton <jwe@octave.org>
parents: 24480
diff changeset
163 if (sk > 0)
dac2ad033c43 use same wording and order for individual test results and summary
John W. Eaton <jwe@octave.org>
parents: 24480
diff changeset
164 printf ("\n%71s %3d", "(missing feature) SKIP", sk);
dac2ad033c43 use same wording and order for individual test results and summary
John W. Eaton <jwe@octave.org>
parents: 24480
diff changeset
165 endif
dac2ad033c43 use same wording and order for individual test results and summary
John W. Eaton <jwe@octave.org>
parents: 24480
diff changeset
166 if (rtsk > 0)
dac2ad033c43 use same wording and order for individual test results and summary
John W. Eaton <jwe@octave.org>
parents: 24480
diff changeset
167 printf ("\n%71s %3d", "(run-time condition) SKIP", rtsk);
dac2ad033c43 use same wording and order for individual test results and summary
John W. Eaton <jwe@octave.org>
parents: 24480
diff changeset
168 endif
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 endif
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
170 puts ("\n");
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21634
diff changeset
171
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 endfunction
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 function print_test_file_name (nm)
24480
04d1a3ea26a3 runtests.m: Update printing of output.
Rik <rik@octave.org>
parents: 23220
diff changeset
175 filler = repmat (".", 1, 60-length (nm));
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
176 printf (" %s %s", nm, filler);
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 endfunction
17148
fa14aa77b514 Allow relative directory name for rundemos/runtests.
Rik <rik@octave.org>
parents: 16724
diff changeset
178
fa14aa77b514 Allow relative directory name for rundemos/runtests.
Rik <rik@octave.org>
parents: 16724
diff changeset
179
27115
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
180 %!error oruntests ("foo", 1)
8a04f5454350 Deprecate 'runtests' function (bug #56325).
Rik <rik@octave.org>
parents: 26376
diff changeset
181 %!error <DIRECTORY argument> oruntests ("#_TOTALLY_/_INVALID_/_PATHNAME_#")