Mercurial > octave-antonio
annotate scripts/testfun/rundemos.m @ 16724:b7667fcb9fbc
Substitute ostrsplit() for strsplit().
The function ostrsplit() is Octave's original strsplit(), and strsplit()
has been modified to be compatible with Matlab's version. Bug #39010.
* scripts/deprecated/javafields.m: Change call to ostrsplit().
* scripts/deprecated/javamethods.m: ditto
* scripts/general/fieldnames.m: ditto
* scripts/general/int2str.m: ditto
* scripts/general/methods.m: ditto
* scripts/general/num2str.m: ditto
* scripts/help/gen_doc_cache.m: ditto
* scripts/help/help.m: ditto
* scripts/help/lookfor.m: ditto
* scripts/io/strread.m: ditto
* scripts/java/javaclasspath.m: ditto
* scripts/miscellaneous/compare_versions.m: ditto
* scripts/miscellaneous/computer.m: ditto
* scripts/miscellaneous/fact.m: ditto
* scripts/miscellaneous/tar.m: ditto
* scripts/miscellaneous/unpack.m: ditto
* scripts/miscellaneous/what.m: ditto
* scripts/miscellaneous/zip.m: ditto
* scripts/pkg/private/configure_make.m: ditto
* scripts/pkg/private/fix_depends.m: ditto
* scripts/pkg/private/generate_lookfor_cache.m: ditto
* scripts/pkg/private/list_forge_packages.m: ditto
* scripts/pkg/private/unload_packages.m: ditto
* scripts/pkg/private/write_index.m: ditto
* scripts/plot/private/__file_filter__.m: ditto
* scripts/plot/private/__fltk_file_filter__.m: ditto
* scripts/plot/private/__go_draw_axes__.m: ditto
* scripts/plot/private/__next_line_style__.m: ditto
* scripts/testfun/rundemos.m: ditto
* scripts/testfun/runtests.m: ditto
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 06 Jun 2013 10:06:12 +0800 |
parents | 1de4ec2a856d |
children | fa14aa77b514 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14087
diff
changeset
|
1 ## Copyright (C) 2008-2012 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) | |
16724
b7667fcb9fbc
Substitute ostrsplit() for strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
33 dirs = ostrsplit (path (), pathsep ()); |
8229 | 34 elseif (nargin == 1) |
35 if (is_absolute_filename (directory)) | |
36 dirs = {directory}; | |
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(),'$'], ""); |
8229 | 39 fullname = find_dir_in_path (directory); |
40 if (! isempty (fullname)) | |
10549 | 41 dirs = {fullname}; |
8229 | 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:
10635
diff
changeset
|
43 error ("rundemos: DIRECTORY argument must be a valid pathname"); |
8229 | 44 endif |
45 endif | |
46 else | |
47 print_usage (); | |
48 endif | |
49 | |
8231
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
50 for i = 1:numel (dirs) |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
51 d = dirs{i}; |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
52 run_all_demos (d); |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
53 endfor |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
54 |
8229 | 55 endfunction |
56 | |
57 function run_all_demos (directory) | |
58 dirinfo = dir (directory); | |
59 flist = {dirinfo.name}; | |
60 for i = 1:numel (flist) | |
61 f = flist{i}; | |
62 if (length (f) > 2 && strcmp (f((end-1):end), ".m")) | |
63 f = fullfile (directory, f); | |
64 if (has_demos (f)) | |
14087
8782d41893c6
Add try-catch block to rundemos.
Ben Abbott <bpabbott@mac.com>
parents:
13065
diff
changeset
|
65 try |
8782d41893c6
Add try-catch block to rundemos.
Ben Abbott <bpabbott@mac.com>
parents:
13065
diff
changeset
|
66 demo (f); |
8782d41893c6
Add try-catch block to rundemos.
Ben Abbott <bpabbott@mac.com>
parents:
13065
diff
changeset
|
67 catch |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
14237
diff
changeset
|
68 printf ("error: %s\n\n", lasterror().message); |
14087
8782d41893c6
Add try-catch block to rundemos.
Ben Abbott <bpabbott@mac.com>
parents:
13065
diff
changeset
|
69 end_try_catch |
10549 | 70 if (i != numel (flist)) |
71 input ("Press <enter> to continue: ", "s"); | |
72 endif | |
8229 | 73 endif |
74 endif | |
75 endfor | |
76 endfunction | |
77 | |
78 function retval = has_demos (f) | |
79 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
|
80 if (f < 0) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
81 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
|
82 else |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
83 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
|
84 fclose (fid); |
14214
2fe0f5fa8cc3
Replace to-be-deprecated findstr occurrences with strfind.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
85 retval = strfind (str, "%!demo"); |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
86 endif |
8229 | 87 endfunction |
13065
1ca3cde15b18
codepsprint: tests for testfun functions
John W. Eaton <jwe@octave.org>
parents:
12673
diff
changeset
|
88 |
14214
2fe0f5fa8cc3
Replace to-be-deprecated findstr occurrences with strfind.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
89 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14214
diff
changeset
|
90 %!error rundemos ("foo", 1) |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14214
diff
changeset
|
91 %!error <DIRECTORY argument> rundemos ("#_TOTALLY_/_INVALID_/_PATHNAME_#") |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14214
diff
changeset
|
92 |