Mercurial > hg > octave-lyh
annotate scripts/testfun/runtests.m @ 16447:e3b33a7530bc
improve encapsulation of history window object
* history-dockwidget.h, history-dockwidget.cc
(history_dock_widget::history_dock_widget): Set status tip here.
Connect history_dock_widget::information signal to
main_window::report_status_message.
Connect history_dock_widget::command_double_clicked signal to
main_window::handle_command_double_clicked.
(history_dock_widget::connect_visibility_changed,
history_dock_widget::focus, history_dock_widget::handle_visibility):
New functions.
* main-window.h, main-window.cc (main_window::history_window): Rename
from _history_dock_widget. Don't use a pointer. Change all uses.
(main_window::main_window): Initialize it here.
(main_window::~main_window): Don't delete _history_dock_widget.
(main_window::focus_history_window_signal): New signal.
(main_window::focus_history_window): Rename from
main_window::focus_command_history. Emit focus_history_window_signal
instead of performing actions here.
(main_window::handle_command_history_visible): Delete.
(main_window::connect_visibility_changed): Call
history_window.connect_visibility_changed instead of performing
actions here.
(main_window::construct): Don't create _history_dock_widget. Adapt
signal/slot connections for new history_window object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 06 Apr 2013 16:46:14 -0400 |
parents | 1de4ec2a856d |
children | b7667fcb9fbc |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12673
diff
changeset
|
1 ## Copyright (C) 2010-2012 John W. Eaton |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 ## |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 ## |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 ## your option) any later version. |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 ## |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 ## 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
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 ## General Public License for more details. |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 ## |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 ## 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
|
16 ## along with Octave; see the file COPYING. If not, see |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
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 ## -*- texinfo -*- |
12668
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
20 ## @deftypefn {Function File} {} runtests () |
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
21 ## @deftypefnx {Function File} {} runtests (@var{directory}) |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
22 ## Execute built-in tests for all function files in the specified directory. |
12668
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
23 ## If no directory is specified, operate on all directories in Octave's |
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
24 ## search path for functions. |
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
12469
diff
changeset
|
25 ## @seealso{rundemos, path} |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 ## @end deftypefn |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 ## Author: jwe |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 function runtests (directory) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 if (nargin == 0) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
33 dirs = strsplit (path (), pathsep (), false); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 elseif (nargin == 1) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 if (is_absolute_filename (directory)) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 dirs = {directory}; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 else |
12673
64193afe93d8
runtests.m, rundemos.m: Remove final filesep() character from directory name
Rik <octave@nomad.inbox5.com>
parents:
12668
diff
changeset
|
38 directory = regexprep (directory, ['\',filesep(),'$'], ""); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 fullname = find_dir_in_path (directory); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 if (! isempty (fullname)) |
10549 | 41 dirs = {fullname}; |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 else |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
43 error ("runtests: DIRECTORY argument must be a valid pathname"); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 else |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 print_usage (); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 for i = 1:numel (dirs) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 d = dirs{i}; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 run_all_tests (d); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 endfor |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 endfunction |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 function run_all_tests (directory) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 dirinfo = dir (directory); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 flist = {dirinfo.name}; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 no_tests = {}; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 printf ("Processing files in %s:\n\n", directory); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 fflush (stdout); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 for i = 1:numel (flist) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 f = flist{i}; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 if (length (f) > 2 && strcmp (f((end-1):end), ".m")) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 ff = fullfile (directory, f); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 if (has_tests (ff)) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 print_test_file_name (f); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 [p, n, xf, sk] = test (ff, "quiet"); |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
70 print_pass_fail (n, p); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 fflush (stdout); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 else |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 no_tests{end+1} = f; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 endfor |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 if (! isempty (no_tests)) |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
78 printf ("\nThe following files in %s have no tests:\n\n", directory); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 printf ("%s", list_in_columns (no_tests)); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 endfunction |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 function retval = has_tests (f) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 fid = fopen (f); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 if (fid >= 0) |
11024
fa56fd98c0c5
Remove requirement for PCRE in Octave. (Bug #31025)
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
86 str = fread (fid, "*char")'; |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 fclose (fid); |
12469
0ee8d7d60c82
Use single quotes around regexp patterns.
Rik <octave@nomad.inbox5.com>
parents:
12462
diff
changeset
|
88 retval = ! isempty (regexp (str, '^%!(test|assert|error|warning)', "lineanchors")); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
90 error ("runtests: fopen failed: %s", f); |
10496
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 endfunction |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 function print_pass_fail (n, p) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 if (n > 0) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 printf (" PASS %4d/%-4d", p, n); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 nfail = n - p; |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 if (nfail > 0) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 printf (" FAIL %d", nfail); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 endif |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 puts ("\n"); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 endfunction |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 function print_test_file_name (nm) |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 filler = repmat (".", 1, 55-length (nm)); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 printf (" %s %s", nm, filler); |
3b77db443cc0
scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 endfunction |