0001 function [errors warnings] = tutorials_test(directory,tcount)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if nargin<1 || isempty(directory)
0019 directory = '../../htdocs/tutorial/';
0020
0021 end
0022 diary tutorial_status.txt
0023
0024 global my_dir; my_dir = cd;
0025 cd(directory);
0026 global tut_dir; tut_dir = cd;
0027 global D; D = genpath('.');
0028 global d;
0029
0030 warning off all
0031 eidors_msg('log_level',0);
0032 pause off
0033
0034
0035 global tut_dlm;
0036 if strcmp(computer,'PCWIN') || strcmp(computer,'PCWIN64')
0037 tut_dlm = ';';
0038 else
0039 tut_dlm = ':';
0040 end
0041
0042 global tut_count; tut_count = 0;
0043 global last_tut;
0044 if nargin >1,
0045 last_tut = tcount;
0046 else last_tut = 0;
0047 end
0048 [d,D]= strtok(D,tut_dlm);
0049 while ~isempty(d)
0050 if ~isempty(strfind(d,'.svn'));
0051 [d,D]= strtok(D,tut_dlm);
0052 continue;
0053 end;
0054 try
0055 cd(d);
0056 catch
0057 keyboard
0058 end
0059 global F;F = dir('*.m');
0060 F = struct2cell(F); F = sortrows(F(1,:));
0061 global errors; errors={};
0062 global e_count; e_count = 1;
0063 global w_count; w_count = 1;
0064 global warnings; warnings={};
0065
0066
0067 while length(F) > 0
0068 evalin('base','clear');
0069 calc_colours('defaults');
0070 clf;
0071 tutname = F{1};
0072
0073 tutname(end-3) = '*';
0074 tutname(end-2) = [];
0075 T = dir(tutname);
0076 if any(strcmp( T(1).name, skiplist));
0077 F(1:length(T)) = [];
0078 continue;
0079 end
0080 while length(T) > 0
0081 calc_colours('defaults');
0082 if length(T(1).name)>length(tutname)+2
0083 T(1) = [];
0084 continue
0085 end
0086 name = T(1).name(1:end-2);
0087 skip = 0;
0088 if isfunction(name)
0089 skip = 1;
0090 else
0091 tut_count = tut_count +1;
0092 end
0093 if skip || tut_count < last_tut
0094 T(1) = [];
0095 F(1) = [];
0096 continue
0097 end
0098 fprintf([num2str(tut_count,'%04d') ' ' strrep(d,'\','\\') '\\' name]);
0099 lastwarn('');
0100 save tmp
0101 try
0102 evalin('base',sprintf('evalc(''%s'');',name));
0103
0104 if ~isempty(lastwarn)
0105 fprintf(' WARNING(S) = (%s)\n',lastwarn);
0106 warnings{w_count,1} = T(1).name;
0107 warnings{w_count,1} = d;
0108 w_count = w_count+1;
0109 else
0110 fprintf(' OK\n');
0111 end
0112 load tmp
0113 delete('tmp.mat');
0114 global warnings w_count;
0115 catch
0116 load tmp
0117 delete('tmp.mat');
0118 errors{e_count,1} = T(1).name;
0119 L = lasterror();
0120 errors{e_count,2} = d;
0121 errors{e_count,3} = L.message;
0122 e_count = e_count + 1;
0123 fprintf(' ERROR = (%s)\n',L.message);
0124 end
0125
0126 T(1) = [];
0127 F(1) = [];
0128
0129 end
0130 clear; clf;
0131 global F tut_count e_count errors warnings w_count d D my_dir tut_dir tut_dlm last_tut
0132 end
0133 cd(tut_dir);
0134 [d,D]= strtok(D,tut_dlm);
0135 end
0136
0137
0138
0139 warning on all
0140 eidors_msg('log_level',2);
0141 pause on
0142 clear global F tut_count e_count errors warnings w_count
0143 cd(my_dir)
0144 diary off
0145
0146 function sl = skiplist
0147 sl = {'netgen_accuracy01.m', ...
0148 'common_models01.m', ...
0149 'Script_For_Tutorial.m'};
0150
0151
0152
0153 function flag = isfunction(fname)
0154 fid = fopen([fname '.m']);
0155 l = fgetl(fid);
0156 fclose(fid);
0157 t = strtok(l);
0158 flag = strcmp(t,'function');
0159