-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunExamples.m
More file actions
65 lines (59 loc) · 1.95 KB
/
RunExamples.m
File metadata and controls
65 lines (59 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function [names,status] = RunExamples(str,varargin)
% Invoke examples for all files in a directory or a function
%
% [names,status] = RunExamples(fileOrDirectory, ...);
%
% Copyright ISETBIO Team, 2018
%
% See also
% ExecuteExamplesInFunction, ExecuteExamplesInDirectory, PrintExamples
% Examples:
%{
% Exercise ExampleTestToolbox
theDir = fileparts(which('RunExamples'));
ExecuteExamplesInFunction(fullfile(theDir,'ExecuteExamplesInDirectory.m'));
ExecuteExamplesInFunction(fullfile(theDir,'ExecuteExamplesInFunction.m'));
ExecuteExamplesInFunction(fullfile(theDir,'PrintExamples.m'));
%}
%{
% Requires ISETBio on path.
if (exist('opticsGet','file'))
[names,status] = RunExamples('opticsGet.m','findflag',true,'printflag',true);
[names,status] = RunExamples('opticsGet.m','findflag',true,'printflag',false);
[names,status] = RunExamples('opticsGet.m','findflag',true,'printflag',false, ...
'closefigs',false);
end
%}
%{
% Requires ISETBio on path
if (exist('isetbioRootPath','file'))
directory = fullfile(isetbioRootPath,'isettools','opticalimage');
[names,status] = RunExamples(directory,'findflag',true,'printflag',false);
end
%}
%%
p = inputParser;
p.addRequired('str',@ischar);
p.addParameter('printflag',false,@islogical);
p.addParameter('findflag',true,@islogical);
p.addParameter('verbose',false,@islogical);
p.addParameter('closefigs',true,@islogical);
p.parse(str,varargin{:});
pFlag = p.Results.printflag;
fFlag = p.Results.findflag;
verbose = p.Results.verbose;
%%
if exist(str,'dir')
[names,status] = ExecuteExamplesInDirectory(str, ...
'verbose',verbose, ...
'closefigs',p.Results.closefigs);
elseif exist(str,'file')
names = str;
status = ExecuteExamplesInFunction(str,'findfunction',fFlag,...
'printexampletext',pFlag,...
'verbose',verbose, ...
'closefigs',p.Results.closefigs);
else
error('No file or directory %s\n',str);
end
end