Merge branch 'master' of https://github.com/DynareTeam/dynare
commit
5c52cd76c0
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function sp = colon(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function date = dynDate(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = eq(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function p = format(date)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = ge(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = gt(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function b = isempty(a)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = le(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = lt(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = max(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = min(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = minus(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = ne(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function c = plus(a,b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function B = subsref(A,S)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function b = uminus(a)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function b = uplus(a)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function dd = append(dd,a)
|
||||
% append method for dynDates class.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function dd = dynDates(varargin)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function C = eq(A,B)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function C = intersect(A,B)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function B = isempty(A)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function C = minus(A,B)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function C = plus(A,B)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function dd = pop(dd,a)
|
||||
% pop method for dynDates class (removes a date)).
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function dd = sort(dd)
|
||||
% sort method for dynDates class.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function B = subsref(A,S)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function C = union(A,varargin)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function dd = unique(dd)
|
||||
% unique method for dynDates class.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function [a,b] = align(a, b)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function ts = dynSeries(varargin)
|
||||
|
||||
%@info:
|
||||
|
@ -124,13 +125,18 @@ switch nargin
|
|||
ts.vobs = length(varlist);
|
||||
ts.nobs = size(data,1);
|
||||
if isempty(tex)
|
||||
ts.tex = cell(ts.vobs,1);
|
||||
for i=1:ts.vobs
|
||||
ts.tex(i) = {name2tex(varlist{i})};
|
||||
end
|
||||
ts.tex = name2tex(varlist);
|
||||
else
|
||||
ts.tex = tex;
|
||||
ts.tex = tex;
|
||||
end
|
||||
elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2)
|
||||
ts.data = varargin{1};
|
||||
[ts.nobs, ts.vobs] = size(ts.data);
|
||||
ts.freq = 1;
|
||||
ts.init = dynDate(1);
|
||||
ts.time = ts.init:ts.init+ts.nobs;
|
||||
ts.name = default_name(ts.vobs);
|
||||
ts.tex = name2tex(ts.name);
|
||||
end
|
||||
case {2,3,4}
|
||||
a = varargin{1};
|
||||
|
@ -177,9 +183,7 @@ switch nargin
|
|||
error('dynSeries::dynSeries: The number of declared names does not match the number of variables!')
|
||||
end
|
||||
else
|
||||
for i=1:ts.vobs
|
||||
ts.name = vertcat(ts.name, {['Variable_' int2str(i)]});
|
||||
end
|
||||
ts.name = default_name(ts.vobs);
|
||||
end
|
||||
if ~isempty(d)
|
||||
if ts.vobs==length(d)
|
||||
|
@ -190,9 +194,7 @@ switch nargin
|
|||
error('dynSeries::dynSeries: The number of declared tex names does not match the number of variables!')
|
||||
end
|
||||
else
|
||||
for i=1:ts.vobs
|
||||
ts.tex = vertcat(ts.tex, {name2tex(ts.name{i})});
|
||||
end
|
||||
ts.tex = name2tex(ts.name);
|
||||
end
|
||||
otherwise
|
||||
error('dynSeries::dynSeries: Can''t instantiate the class, wrong calling sequence!')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function C = eq(A,B)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = extract(B,varargin)
|
||||
% Extract some variables from a database.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function a = horzcat(varargin)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function ts = insert(ts,us,id)
|
||||
% Add a variable in a dynSeries object.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function us = lag(ts,p)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = merge(B,C)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{A} =} merge (@var{B},@var{C})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = minus(B,C)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{A} =} minus (@var{B},@var{C})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = mrdivide(B,C)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{A} =} mrdivide (@var{B},@var{C})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = mtimes(B,C)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{A} =} mtimes (@var{B},@var{C})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = plus(B,C)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function [ts,id] = pop(ts,a)
|
||||
% Removes a variable from a dynSeries object.
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
function names = default_name(dim)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
names = {};
|
||||
for i=1:dim
|
||||
names = vertcat(names, {['Variable_' int2str(i)]});
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function us = qdiff(ts)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function us = qgrowth(ts)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function ts = rename(ts,old,new)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function save(A,basename,format)
|
||||
% Saves a dynSeries object on disk.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = set_names(B,varargin)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = subsasgn(A,S,B)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function B = subsref(A, S)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{us} =} subsref (@var{ts},S)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function ts = tex_rename(ts, varargin)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function A = uminus(B)
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function a = vertcat(varargin)
|
||||
|
||||
%@info:
|
||||
|
@ -30,7 +31,7 @@ function a = vertcat(varargin)
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2011-2013 Dynare Team
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
% --*-- Unitary tests --*--
|
||||
function us = ydiff(ts)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function us = ygrowth(ts)
|
||||
|
||||
%@info:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch)
|
||||
|
||||
%@info:
|
||||
|
@ -43,7 +44,7 @@ function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch)
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2012 Dynare Team
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -112,23 +113,39 @@ if (nargin == 5 && ~isempty(ch) )
|
|||
end
|
||||
|
||||
%@test:1
|
||||
%$ addpath ../matlab
|
||||
%$
|
||||
%$ % Set the dimension of the problem to be solved
|
||||
%$ t = zeros(3,1);
|
||||
%$
|
||||
%$ % Set the dimension of the problem to be solved.
|
||||
%$ n = 2000;
|
||||
%$
|
||||
%$ % Set the equation to be solved
|
||||
%$ A = eye(n);
|
||||
%$ B = diag(30*ones(n,1)); B(1,1) = 20; B(end,end) = 20; B = B - diag(10*ones(n-1,1),-1); B = B - diag(10*ones(n-1,1),1);
|
||||
%$ C = diag(15*ones(n,1)); C = C - diag(5*ones(n-1,1),-1); C = C - diag(5*ones(n-1,1),1);
|
||||
%$
|
||||
%$ % Solve the equation with the cycle reduction algorithm
|
||||
%$ tic, X1 = cycle_reduction(C,B,A,1e-7); toc
|
||||
%$ try
|
||||
%$ t=cputime; X1 = cycle_reduction(C,B,A,1e-7); elapsedtime = cputime-t;
|
||||
%$ disp(['cputime for cycle reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').'])
|
||||
%$ t(1) = 1;
|
||||
%$ catch
|
||||
%$ % nothing to do here.
|
||||
%$ end
|
||||
%$
|
||||
%$ % Solve the equation with the logarithmic reduction algorithm
|
||||
%$ tic, X2 = logarithmic_reduction(A,B,C,1e-16,100); toc
|
||||
%$ try
|
||||
%$ t=cputime; X2 = logarithmic_reduction(A,B,C,1e-16,100); elapsedtime = cputime-t;
|
||||
%$ disp(['cputime for logarithmic reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').'])
|
||||
%$ t(2) = 1;
|
||||
%$ catch
|
||||
%$ % nothing to do here.
|
||||
%$ end
|
||||
%$
|
||||
%$ % Check the results.
|
||||
%$ t(1) = dyn_assert(X1,X2,1e-12);
|
||||
%$ if t(1) && t(2)
|
||||
%$ t(3) = dyn_assert(X1,X2,1e-12);
|
||||
%$ end
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:1
|
|
@ -1,103 +0,0 @@
|
|||
function tex = name2tex(name, info)
|
||||
% Converts plain text name into tex name.
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if nargin<2
|
||||
info = 0;
|
||||
end
|
||||
|
||||
id = findstr('_',name);
|
||||
if isempty(id)
|
||||
tex = name;
|
||||
return
|
||||
end
|
||||
|
||||
if info
|
||||
tex = name;
|
||||
n = length(id);
|
||||
if id(1)==1
|
||||
tex = ['\_', tex(2:end)];
|
||||
if n>1
|
||||
id = id(2:end)+1;
|
||||
n = n-1;
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
if id(end)==length(tex)
|
||||
tex = [tex(1:end-1) '\_'];
|
||||
if n>1
|
||||
id = id(1:end-1);
|
||||
n = n-1;
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
if n==1
|
||||
tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ];
|
||||
return
|
||||
else
|
||||
for i=1:n-1
|
||||
tex = [tex(1:id(1)-1) '\_' tex((id(1)+1):end)];
|
||||
id = id(2:end)+1;
|
||||
end
|
||||
tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}'];
|
||||
end
|
||||
else
|
||||
tex = strrep(name, '_', '\_');
|
||||
end
|
||||
|
||||
%@test:1
|
||||
%$ t = zeros(16,1);
|
||||
%$ t1 = name2tex('_azert');
|
||||
%$ t2 = name2tex('azert_');
|
||||
%$ t3 = name2tex('_azert_');
|
||||
%$ t4 = name2tex('azert_uiop');
|
||||
%$ t5 = name2tex('azert_uiop_qsdfg');
|
||||
%$ t6 = name2tex('azert_uiop_qsdfg_');
|
||||
%$ t7 = name2tex('_azert_uiop_qsdfg');
|
||||
%$ t8 = name2tex('_azert_uiop_qsdfg_');
|
||||
%$ t11 = name2tex('_azert',1);
|
||||
%$ t12 = name2tex('azert_',1);
|
||||
%$ t13 = name2tex('_azert_',1);
|
||||
%$ t14 = name2tex('azert_uiop',1);
|
||||
%$ t15 = name2tex('azert_uiop_qsdfg',1);
|
||||
%$ t16 = name2tex('azert_uiop_qsdfg_',1);
|
||||
%$ t17 = name2tex('_azert_uiop_qsdfg',1);
|
||||
%$ t18 = name2tex('_azert_uiop_qsdfg_',1);
|
||||
%$
|
||||
%$ t(1) = dyn_assert(strcmp(t1,'\\_azert'),1);
|
||||
%$ t(2) = dyn_assert(strcmp(t2,'azert\\_'),1);
|
||||
%$ t(3) = dyn_assert(strcmp(t3,'\\_azert\\_'),1);
|
||||
%$ t(4) = dyn_assert(strcmp(t4,'azert\\_uiop'),1);
|
||||
%$ t(5) = dyn_assert(strcmp(t5,'azert\\_uiop\\_qsdfg'),1);
|
||||
%$ t(6) = dyn_assert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),1);
|
||||
%$ t(7) = dyn_assert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),1);
|
||||
%$ t(8) = dyn_assert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),1);
|
||||
%$ t(9) = dyn_assert(strcmp(t11,'\\_azert'),1);
|
||||
%$ t(10) = dyn_assert(strcmp(t12,'azert\\_'),1);
|
||||
%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1);
|
||||
%$ t(12) = dyn_assert(strcmp(t14,'azert_{uiop}'),1);
|
||||
%$ t(13) = dyn_assert(strcmp(t15,'azert\\_uiop_{qsdfg}'),1);
|
||||
%$ t(14) = dyn_assert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),1);
|
||||
%$ t(15) = dyn_assert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),1);
|
||||
%$ t(16) = dyn_assert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),1);
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:1
|
|
@ -0,0 +1,218 @@
|
|||
% --*-- Unitary tests --*--
|
||||
function tex = name2tex(name, info)
|
||||
% Converts plain text name into tex name.
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if nargin<2
|
||||
info = 0;
|
||||
end
|
||||
|
||||
if iscell(name)
|
||||
nn = length(name);
|
||||
id = findstr(cell2mat(transpose(name)),'_');
|
||||
else
|
||||
nn = 1;
|
||||
id = findstr(name,'_');
|
||||
end
|
||||
|
||||
if isempty(id)
|
||||
tex = name;
|
||||
return
|
||||
end
|
||||
|
||||
if iscell(name)
|
||||
tex = cell(nn,1);
|
||||
end
|
||||
|
||||
for i=1:nn
|
||||
if info
|
||||
if iscell(name)
|
||||
tex(i) = {name{i}};
|
||||
id = findstr(name{i},'_');
|
||||
len = length(tex{i});
|
||||
else
|
||||
tex = name;
|
||||
id = findstr(name,'_');
|
||||
len = length(tex);
|
||||
end
|
||||
n = length(id);
|
||||
if id(1)==1
|
||||
if iscell(name)
|
||||
tex(i) = {['\_', tex{i}(2:end)]};
|
||||
else
|
||||
tex = ['\_', tex(2:end)];
|
||||
end
|
||||
if n>1
|
||||
id = id(2:end)+1;
|
||||
n = n-1;
|
||||
len = len+1;
|
||||
else
|
||||
continue
|
||||
end
|
||||
end
|
||||
if id(end)==len
|
||||
if iscell(name)
|
||||
tex(i) = {[tex{i}(1:end-1) '\_']};
|
||||
else
|
||||
tex = [tex(1:end-1) '\_'];
|
||||
end
|
||||
if n>1
|
||||
id = id(1:end-1);
|
||||
n = n-1;
|
||||
else
|
||||
continue
|
||||
end
|
||||
end
|
||||
if n==1
|
||||
if iscell(name)
|
||||
tex(i) = {[ tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}' ]};
|
||||
else
|
||||
tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ];
|
||||
end
|
||||
continue
|
||||
else
|
||||
for j=1:n-1
|
||||
if iscell(name)
|
||||
tex(i) = {[tex{i}(1:id(j)-1) '\_' tex{i}((id(j)+1):end)]};
|
||||
else
|
||||
tex = [tex(1:id(j)-1) '\_' tex((id(j)+1):end)];
|
||||
end
|
||||
id = id(2:end)+1;
|
||||
end
|
||||
if iscell(name)
|
||||
tex(i) = {[tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}']};
|
||||
else
|
||||
tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}'];
|
||||
end
|
||||
end
|
||||
else
|
||||
if iscell(name)
|
||||
tex(i) = {strrep(name{i}, '_', '\_')};
|
||||
else
|
||||
tex = strrep(name, '_', '\_');
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%@test:1
|
||||
%$ t = zeros(16,1);
|
||||
%$ t1 = name2tex('_azert');
|
||||
%$ t2 = name2tex('azert_');
|
||||
%$ t3 = name2tex('_azert_');
|
||||
%$ t4 = name2tex('azert_uiop');
|
||||
%$ t5 = name2tex('azert_uiop_qsdfg');
|
||||
%$ t6 = name2tex('azert_uiop_qsdfg_');
|
||||
%$ t7 = name2tex('_azert_uiop_qsdfg');
|
||||
%$ t8 = name2tex('_azert_uiop_qsdfg_');
|
||||
%$ t11 = name2tex('_azert',1);
|
||||
%$ t12 = name2tex('azert_',1);
|
||||
%$ t13 = name2tex('_azert_',1);
|
||||
%$ t14 = name2tex('azert_uiop',1);
|
||||
%$ t15 = name2tex('azert_uiop_qsdfg',1);
|
||||
%$ t16 = name2tex('azert_uiop_qsdfg_',1);
|
||||
%$ t17 = name2tex('_azert_uiop_qsdfg',1);
|
||||
%$ t18 = name2tex('_azert_uiop_qsdfg_',1);
|
||||
%$
|
||||
%$ t(1) = dyn_assert(strcmp(t1,'\\_azert'),1);
|
||||
%$ t(2) = dyn_assert(strcmp(t2,'azert\\_'),1);
|
||||
%$ t(3) = dyn_assert(strcmp(t3,'\\_azert\\_'),1);
|
||||
%$ t(4) = dyn_assert(strcmp(t4,'azert\\_uiop'),1);
|
||||
%$ t(5) = dyn_assert(strcmp(t5,'azert\\_uiop\\_qsdfg'),1);
|
||||
%$ t(6) = dyn_assert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),1);
|
||||
%$ t(7) = dyn_assert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),1);
|
||||
%$ t(8) = dyn_assert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),1);
|
||||
%$ t(9) = dyn_assert(strcmp(t11,'\\_azert'),1);
|
||||
%$ t(10) = dyn_assert(strcmp(t12,'azert\\_'),1);
|
||||
%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1);
|
||||
%$ t(12) = dyn_assert(strcmp(t14,'azert_{uiop}'),1);
|
||||
%$ t(13) = dyn_assert(strcmp(t15,'azert\\_uiop_{qsdfg}'),1);
|
||||
%$ t(14) = dyn_assert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),1);
|
||||
%$ t(15) = dyn_assert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),1);
|
||||
%$ t(16) = dyn_assert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),1);
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:1
|
||||
|
||||
%@test:2
|
||||
%$ t = zeros(16,1);
|
||||
%$ t1 = name2tex({'_azert'});
|
||||
%$ t2 = name2tex({'azert_'});
|
||||
%$ t3 = name2tex({'_azert_'});
|
||||
%$ t4 = name2tex({'azert_uiop'});
|
||||
%$ t5 = name2tex({'azert_uiop_qsdfg'});
|
||||
%$ t6 = name2tex({'azert_uiop_qsdfg_'});
|
||||
%$ t7 = name2tex({'_azert_uiop_qsdfg'});
|
||||
%$ t8 = name2tex({'_azert_uiop_qsdfg_'});
|
||||
%$ t11 = name2tex({'_azert'},1);
|
||||
%$ t12 = name2tex({'azert_'},1);
|
||||
%$ t13 = name2tex({'_azert_'},1);
|
||||
%$ t14 = name2tex({'azert_uiop'},1);
|
||||
%$ t15 = name2tex({'azert_uiop_qsdfg'},1);
|
||||
%$ t16 = name2tex({'azert_uiop_qsdfg_'},1);
|
||||
%$ t17 = name2tex({'_azert_uiop_qsdfg'},1);
|
||||
%$ t18 = name2tex({'_azert_uiop_qsdfg_'},1);
|
||||
%$
|
||||
%$ t(1) = dyn_assert(t1,{'\\_azert'});
|
||||
%$ t(2) = dyn_assert(t2,{'azert\\_'});
|
||||
%$ t(3) = dyn_assert(t3,{'\\_azert\\_'});
|
||||
%$ t(4) = dyn_assert(t4,{'azert\\_uiop'});
|
||||
%$ t(5) = dyn_assert(t5,{'azert\\_uiop\\_qsdfg'});
|
||||
%$ t(6) = dyn_assert(t6,{'azert\\_uiop\\_qsdfg\\_'});
|
||||
%$ t(7) = dyn_assert(t7,{'\\_azert\\_uiop\\_qsdfg'});
|
||||
%$ t(8) = dyn_assert(t8,{'\\_azert\\_uiop\\_qsdfg\\_'});
|
||||
%$ t(9) = dyn_assert(t11,{'\\_azert'});
|
||||
%$ t(10) = dyn_assert(t12,{'azert\\_'});
|
||||
%$ t(11) = dyn_assert(t13,{'\\_azert\\_'});
|
||||
%$ t(12) = dyn_assert(t14,{'azert_{uiop}'});
|
||||
%$ t(13) = dyn_assert(t15,{'azert\\_uiop_{qsdfg}'});
|
||||
%$ t(14) = dyn_assert(t16,{'azert\\_uiop_{qsdfg\\_}'});
|
||||
%$ t(15) = dyn_assert(t17,{'\\_azert\\_uiop_{qsdfg}'});
|
||||
%$ t(16) = dyn_assert(t18,{'\\_azert\\_uiop_{qsdfg\\_}'});
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:2
|
||||
|
||||
%@test:3
|
||||
%$ t = zeros(4,1);
|
||||
%$ try
|
||||
%$ t1 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'});
|
||||
%$ t(1) = 1;
|
||||
%$ catch
|
||||
%$ % Nothing to do here.
|
||||
%$ end
|
||||
%$
|
||||
%$ if t(1)
|
||||
%$ try
|
||||
%$ t2 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'},1);
|
||||
%$ t(2) = 1;
|
||||
%$ catch
|
||||
%$ % Nothing to do here.
|
||||
%$ end
|
||||
%$ end
|
||||
%$
|
||||
%$ if t(1)
|
||||
%$ t(3) = dyn_assert(t1,{'\\_azert';'azert\\_';'\\_azert\\_';'azert\\_uiop';'azert\\_uiop\\_qsdfg';'azert\\_uiop\\_qsdfg\\_'});
|
||||
%$ end
|
||||
%$
|
||||
%$ if t(2)
|
||||
%$ t(4) = dyn_assert(t2,{'\\_azert';'azert\\_';'\\_azert\\_';'azert_{uiop}';'azert\\_uiop_{qsdfg}';'azert\\_uiop_{qsdfg\\_}'});
|
||||
%$ end
|
||||
%$
|
||||
%$ T = all(t);
|
||||
%@eof:3
|
|
@ -0,0 +1,101 @@
|
|||
function str = build_report_summary(reportfile, printonscreen, mailreport)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if isequal(nargin,1)
|
||||
printonscreen = 1;
|
||||
mailreport = 0;
|
||||
end
|
||||
|
||||
if nargin<3
|
||||
mailreport = 0;
|
||||
else
|
||||
if ischar(mailreport)
|
||||
mailto = mailreport;
|
||||
mailreport = 1;
|
||||
fid = fopen('~/.matlab-send-report');
|
||||
server = fgetl(fid);
|
||||
fclose(fid);
|
||||
fprintf('\n\n');
|
||||
disp('Send report...')
|
||||
system(['scp ' reportfile ' ' server]);
|
||||
system(['scp ' reportfile(1:end-3) 'log ' server]);
|
||||
else
|
||||
if ~isequal(mailreport,0)
|
||||
error('build_report_summary:: Third argument must be an adress email!')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
reportfilecontent = load(reportfile);
|
||||
reportcell = reportfilecontent.report;
|
||||
gitinfo = reportfilecontent.gitinfo;
|
||||
gitlastcommithash = reportfilecontent.gitlastcommithash;
|
||||
|
||||
str = 'Hi,';
|
||||
str = char(str,'');
|
||||
str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at');
|
||||
str = char(str,'');
|
||||
str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile]);
|
||||
str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile(1:end-3) 'log']);
|
||||
str = char(str,'');
|
||||
str = char(str,gitinfo(1,:));
|
||||
str = char(str,gitinfo(2,:));
|
||||
|
||||
str = char(str,'');
|
||||
str = char(str,'');
|
||||
|
||||
str = char(str,['===========================']);
|
||||
str = char(str,'DYNARE/MATLAB UNITARY TESTS');
|
||||
str = char(str,'===========================');
|
||||
str = char(str,['| TOTAL: ' int2str(size(reportcell,1))]);
|
||||
str = char(str,['| PASS: ' int2str(length(find(cell2mat(reportcell(:,3)))))]);
|
||||
str = char(str,['| FAIL: ' int2str(length(find(~cell2mat(reportcell(:,3)))))]);
|
||||
str = char(str,'|');
|
||||
str = char(str,'| LIST OF FAILED TESTS:');
|
||||
for i=1:size(reportcell,1)
|
||||
if ~reportcell{i,3}
|
||||
str = char(str,['| * ' reportcell{i,1} ' (test #' int2str(reportcell{i,2}) '{' strrep(int2str(transpose(find(~reportcell{i,4}))),' ',',') '})']);
|
||||
end
|
||||
end
|
||||
|
||||
if printonscreen
|
||||
fprintf('\n\n')
|
||||
disp(str)
|
||||
fprintf('\n\n')
|
||||
end
|
||||
|
||||
if mailreport
|
||||
if exist('~/.matlab-send-mail-info','file')
|
||||
fid = fopen('~/.matlab-send-mail-info','r');
|
||||
else
|
||||
disp(['build_report_summary:: I Cannot send the report to ' mailto ' because the sender and the smtp server are not defined!'])
|
||||
disp([' You probably need to add a ''.matlab-send-mail-info'' in your root directory...'])
|
||||
return
|
||||
end
|
||||
setpref('Internet','SMTP_Server',fgetl(fid));
|
||||
setpref('Internet','SMTP_Username',fgetl(fid));
|
||||
setpref('Internet','E_mail',fgetl(fid));
|
||||
setpref('Internet','SMTP_Passeword',fgetl(fid));
|
||||
fclose(fid);
|
||||
STR = [deblank(str(1,:))];
|
||||
for i=2:size(str,1)
|
||||
STR = [STR 10 deblank(str(i,:)) ];
|
||||
end
|
||||
sendmail(mailto,'Dynare/Matlab unitary tests',STR);
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
function flist = get_directory_description(basedir)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dd = dir(basedir);
|
||||
flist = {};
|
||||
file = 1;
|
||||
|
||||
for f=1:length(dd)
|
||||
if ~(isequal(dd(f).name,'.') || isequal(dd(f).name,'..'))
|
||||
if dd(f).isdir
|
||||
flist(file) = { get_directory_description([ basedir filesep dd(f).name]) };
|
||||
else
|
||||
flist(file) = { [basedir filesep dd(f).name] };
|
||||
end
|
||||
file = file + 1;
|
||||
end
|
||||
end
|
|
@ -0,0 +1,52 @@
|
|||
function info = is_unitary_test_available(fun)
|
||||
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{info} =} is_unitary_test_available (@var{fun})
|
||||
%! @anchor{is_unitary_test_available}
|
||||
%! @sp 1
|
||||
%! Tests if matlab/octave routine @var{fun} has unitary tests.
|
||||
%! @sp 2
|
||||
%! @strong{Inputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item fun
|
||||
%! string, name of the matlab/octave routine to be tested.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{Outputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item info
|
||||
%! Integer scalar equal to one if unitary tests are available, zero otherwise.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
info = 0;
|
||||
|
||||
fid = fopen(fun,'r');
|
||||
first_line = fgetl(fid);
|
||||
|
||||
if strcmp(first_line,'% --*-- Unitary tests --*--')
|
||||
info = 1;
|
||||
end
|
||||
|
||||
fclose(fid);
|
|
@ -1,7 +1,7 @@
|
|||
function check = mtest(fname,fpath)
|
||||
function [check, info] = mtest(fname, fpath)
|
||||
% Extract test sections from matlab's routine executes the test and report errors.
|
||||
|
||||
% Copyright (C) 2011-2012 Dynare Team
|
||||
% Copyright (C) 2011-2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -24,7 +24,17 @@ function check = mtest(fname,fpath)
|
|||
check = 1;
|
||||
|
||||
% Open the matlab file.
|
||||
fid = fopen([fpath '/' fname '.m'],'r');
|
||||
if nargin<2 || isempty(fpath)
|
||||
if nargout<2
|
||||
error('mtest:: Wrong calling sequence!')
|
||||
end
|
||||
% The full path to the matlab routine (with extension) is given.
|
||||
fid = fopen(fname,'r');
|
||||
[junk, FNAME, vessel] = fileparts(fname);
|
||||
else
|
||||
fid = fopen([fpath '/' fname '.m'],'r');
|
||||
FNAME = fname;
|
||||
end
|
||||
|
||||
% Read the matlab file.
|
||||
file = textscan(fid,'%s','delimiter','\n');
|
||||
|
@ -42,11 +52,25 @@ if length(b1)-length(b2)
|
|||
error('test:: There is a problem with the test blocks definition!')
|
||||
end
|
||||
|
||||
% Initialize the second output if necessary.
|
||||
if nargout>1
|
||||
% First column name of the tested routine.
|
||||
% Second column number of the unitary test.
|
||||
% Third column status of the unitary test (0 if the test fails, 1 otherwise)
|
||||
% Fourth column details about the failure (vector of integers)
|
||||
% Fifth column elapsed time in seconds (cpu time).
|
||||
info = cell(nn,4);
|
||||
end
|
||||
|
||||
% Perform the tests.
|
||||
for i=1:nn
|
||||
if nargout>1
|
||||
info(i,1) = {fname};
|
||||
info(i,2) = {i};
|
||||
end
|
||||
% Write the temporary test routine.
|
||||
tid = fopen([fname '_test_' int2str(i) '.m'],'w');
|
||||
fprintf(tid,['function [T,t,LOG] = ' fname '_test_' int2str(i) '()\n']);
|
||||
tid = fopen([FNAME '_test_' int2str(i) '.m'],'w');
|
||||
fprintf(tid,['function [T,t,LOG] = ' FNAME '_test_' int2str(i) '()\n']);
|
||||
fprintf(tid,['try\n']);
|
||||
for j=b1(i):b2(i)
|
||||
str = file{j};
|
||||
|
@ -60,24 +84,43 @@ for i=1:nn
|
|||
fprintf(tid,['end\n']);
|
||||
fclose(tid);
|
||||
% Call the temporary test routine.
|
||||
[TestFlag,TestDetails,LOG] = feval([fname '_test_' int2str(i)]);
|
||||
init = cputime;
|
||||
[TestFlag,TestDetails,LOG] = feval([FNAME '_test_' int2str(i)]);
|
||||
time = cputime-init;
|
||||
if isnan(TestFlag)
|
||||
fprintf(['\n'])
|
||||
fprintf(['Call to ' fname ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n'])
|
||||
fprintf(['Call to ' FNAME ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n'])
|
||||
fprintf(['\n'])
|
||||
disp(LOG)
|
||||
check = 0;
|
||||
if nargout>1
|
||||
info(i,3) = {0};
|
||||
end
|
||||
continue
|
||||
end
|
||||
if ~TestFlag
|
||||
fprintf(['Test n°' int2str(i) ' for routine ' fname ' failed (' datestr(now) ')!\n']);
|
||||
if nargout>1
|
||||
info(i,3) = {0};
|
||||
tmp = ones(length(TestDetails),1);
|
||||
end
|
||||
fprintf(['Test n°' int2str(i) ' for routine ' FNAME ' failed (' datestr(now) ')!\n']);
|
||||
for j=1:length(TestDetails)
|
||||
if ~TestDetails(j)
|
||||
if nargout>1
|
||||
tmp(j) = 0;
|
||||
end
|
||||
fprintf(['Output argument n°' int2str(j) ' didn''t give the expected result.\n']);
|
||||
end
|
||||
end
|
||||
info(i,4) = {tmp};
|
||||
info(i,5) = {NaN};
|
||||
check = 0;
|
||||
else
|
||||
delete([fname '_test_' int2str(i) '.m'])
|
||||
if nargout>1
|
||||
info(i,3) = {1};
|
||||
info(i,4) = {ones(length(TestDetails),1)};
|
||||
info(i,5) = {time};
|
||||
end
|
||||
delete([FNAME '_test_' int2str(i) '.m'])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,41 @@
|
|||
function [report, time] = run_unitary_tests(listoffiles)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
report = {};
|
||||
|
||||
for f=1:length(listoffiles)
|
||||
if iscell(listoffiles{f})
|
||||
info = run_unitary_tests(listoffiles{f});
|
||||
report = [report; info];
|
||||
else
|
||||
if isequal(listoffiles{f}(end-1:end),'.m') && isempty(strfind(listoffiles{f},'.#'))
|
||||
if is_unitary_test_available(listoffiles{f})
|
||||
disp(['***** Process unitary tests in ' listoffiles{f}])
|
||||
[check, info] = mtest(listoffiles{f});
|
||||
report = [report; info];
|
||||
else
|
||||
disp(['Booh! No unitary tests available in ' listoffiles{f}])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nargout>1
|
||||
time = clock;
|
||||
end
|
|
@ -0,0 +1,47 @@
|
|||
function report = run_unitary_tests_in_directory(dirname,savereport,printreport,sendreport)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
system('git show --pretty=format:"Last commit %H by %an, %ar %n-> %s" HEAD > git.info');
|
||||
system('git rev-parse HEAD > git.last-commit-hash');
|
||||
|
||||
fid = fopen('git.info');
|
||||
gitinfo = fgetl(fid);
|
||||
gitinfo = char(gitinfo,fgetl(fid));
|
||||
fclose(fid);
|
||||
|
||||
fid = fopen('git.last-commit-hash');
|
||||
gitlastcommithash = fgetl(fid);
|
||||
fclose(fid);
|
||||
|
||||
matlabverion = version;
|
||||
platform = computer;
|
||||
|
||||
listoffiles = get_directory_description(dirname);
|
||||
|
||||
diary(['report-' gitlastcommithash '.log'] )
|
||||
[report, time] = run_unitary_tests(listoffiles)
|
||||
diary off
|
||||
|
||||
if nargin>1 && savereport>0
|
||||
save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash','matlabverion','platform');
|
||||
end
|
||||
|
||||
if nargin>2
|
||||
build_report_summary(['report-' gitlastcommithash '.mat'], printreport, sendreport);
|
||||
end
|
Loading…
Reference in New Issue