Mercurial > octave-antonio
annotate scripts/testfun/rundemos.m @ 12668:e3dc23f7dd54 stable
doc: Improve a few docstrings related to test functions and directories.
* what.m, rundemos.m, runtests.m, dirfns.cc (filesep),
utils.cc (find_dir_in_path): Improve docstrings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 14 May 2011 21:17:20 -0700 |
parents | fd0a3ac60b0e |
children | 64193afe93d8 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2008-2011 John W. Eaton |
8229 | 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 | |
19 ## -*- texinfo -*- | |
12668
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
20 ## @deftypefn {Function File} {} rundemos () |
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
21 ## @deftypefnx {Function File} {} rundemos (@var{directory}) |
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
22 ## Execute built-in demos for all function files in the specified directory. |
e3dc23f7dd54
doc: Improve a few docstrings related to test functions and directories.
Rik <octave@nomad.inbox5.com>
parents:
11523
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:
11523
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:
11523
diff
changeset
|
25 ## @seealso{runtests, path} |
8229 | 26 ## @end deftypefn |
27 | |
28 ## Author: jwe | |
29 | |
30 function rundemos (directory) | |
31 | |
32 if (nargin == 0) | |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
8746
diff
changeset
|
33 dirs = strsplit (path (), pathsep ()); |
8229 | 34 elseif (nargin == 1) |
35 if (is_absolute_filename (directory)) | |
36 dirs = {directory}; | |
37 else | |
38 fullname = find_dir_in_path (directory); | |
39 if (! isempty (fullname)) | |
10549 | 40 dirs = {fullname}; |
8229 | 41 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:
10635
diff
changeset
|
42 error ("rundemos: DIRECTORY argument must be a valid pathname"); |
8229 | 43 endif |
44 endif | |
45 else | |
46 print_usage (); | |
47 endif | |
48 | |
8231
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
49 for i = 1:numel (dirs) |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
50 d = dirs{i}; |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
51 run_all_demos (d); |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
52 endfor |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
53 |
8229 | 54 endfunction |
55 | |
56 function run_all_demos (directory) | |
57 dirinfo = dir (directory); | |
58 flist = {dirinfo.name}; | |
59 for i = 1:numel (flist) | |
60 f = flist{i}; | |
61 if (length (f) > 2 && strcmp (f((end-1):end), ".m")) | |
62 f = fullfile (directory, f); | |
63 if (has_demos (f)) | |
10549 | 64 demo (f); |
65 if (i != numel (flist)) | |
66 input ("Press <enter> to continue: ", "s"); | |
67 endif | |
8229 | 68 endif |
69 endif | |
70 endfor | |
71 endfunction | |
72 | |
73 function retval = has_demos (f) | |
74 fid = fopen (f); | |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
75 if (f < 0) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
76 error ("rundemos: fopen failed: %s", f); |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
77 else |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
78 str = fscanf (fid, "%s"); |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
79 fclose (fid); |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
80 retval = findstr (str, "%!demo"); |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
81 endif |
8229 | 82 endfunction |