From 56ed5bff43e3f40d48b186d95ff40b18473610f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 16 Nov 2023 09:33:27 +0100 Subject: [PATCH] Testsuite: remove useless debug mode from several .m tests The output is always useful (and even needed in case of test failure). --- tests/cyclereduction.m | 46 ++++++++++++------------------------ tests/logarithmicreduction.m | 46 ++++++++++++------------------------ tests/nonlinearsolvers.m | 40 ++++++++----------------------- tests/riccatiupdate.m | 34 ++++++++++---------------- 4 files changed, 52 insertions(+), 114 deletions(-) diff --git a/tests/cyclereduction.m b/tests/cyclereduction.m index 6bf99c004..5c93a18fb 100644 --- a/tests/cyclereduction.m +++ b/tests/cyclereduction.m @@ -1,5 +1,3 @@ -debug = false; - source_dir = getenv('source_root'); addpath([source_dir filesep 'matlab']); @@ -7,10 +5,8 @@ dynare_config; testFailed = 0; -if ~debug - skipline() - disp('*** TESTING: cyclereduction.m ***'); -end +skipline() +disp('*** TESTING: cyclereduction.m ***'); matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'cycle_reduction']; addpath(matlab_cr_path); @@ -37,15 +33,11 @@ try R = norm(C+B*X1+A*X1*X1,1); if (R > cvg_tol) testFailed = testFailed+1; - if debug - dprintf('Matlab cycle_reduction solution is wrong') - end + dprintf('Matlab cycle_reduction solution is wrong') end catch testFailed = testFailed+1; - if debug - dprintf('Matlab cycle_reduction failed') - end + dprintf('Matlab cycle_reduction failed') end % 2. Solve the equation with the Fortran cycle reduction algorithm @@ -56,36 +48,28 @@ try R = norm(C+B*X2+A*X2*X2,1); if (R > cvg_tol) testFailed = testFailed+1; - if debug - dprintf('Fortran cycle_reduction solution is wrong') - end + dprintf('Fortran cycle_reduction solution is wrong') end catch testFailed = testFailed+1; - if debug - dprintf('Fortran cycle_reduction failed') - end + dprintf('Fortran cycle_reduction failed') end % 3. Compare solutions of the Fortran and Matlab routines if (norm(X1 - X2, 1) > cvg_tol) testFailed = testFailed+1; - if debug - dprintf('Fortran and Matlab cycle reduction solutions differ'); - end + dprintf('Fortran and Matlab cycle reduction solutions differ'); end % Compare the Fortran and Matlab execution time -if debug - if tElapsed1 cvg_tol) testFailed = testFailed+1; - if debug - dprintf('Matlab logarithmic_reduction solution is wrong') - end + dprintf('Matlab logarithmic_reduction solution is wrong') end catch testFailed = testFailed+1; - if debug - dprintf('Matlab logarithmic_reduction failed') - end + dprintf('Matlab logarithmic_reduction failed') end % 2. Solve the equation with the Fortran logarithmic reduction algorithm @@ -56,36 +48,28 @@ try R = norm(C+B*X2+A*X2*X2,1); if (R > cvg_tol) testFailed = testFailed+1; - if debug - dprintf('Fortran logarithmic_reduction solution is wrong') - end + dprintf('Fortran logarithmic_reduction solution is wrong') end catch testFailed = testFailed+1; - if debug - dprintf('Fortran logarithmic_reduction failed') - end + dprintf('Fortran logarithmic_reduction failed') end % 3. Compare solutions of the Fortran and Matlab routines if (norm(X1 - X2, 1) > cvg_tol) testFailed = testFailed+1; - if debug - dprintf('Fortran and Matlab logarithmic reduction solutions differ'); - end + dprintf('Fortran and Matlab logarithmic reduction solutions differ'); end % Compare the Fortran and Matlab execution time -if debug - if tElapsed1tolf testFailed = testFailed+1; - if debug - dprintf('Nonlinear solver (mex) failed on %s function (norm(f(x))=%s).', func2str(objfun{i}), num2str(norm(objfun{i}(x)))) - end + dprintf('Nonlinear solver (mex) failed on %s function (norm(f(x))=%s).', func2str(objfun{i}), num2str(norm(objfun{i}(x)))) end end catch testFailed = testFailed+1; - if debug - dprintf('Nonlinear solver (mex) failed on %s function.', func2str(objfun{i})) - end + dprintf('Nonlinear solver (mex) failed on %s function.', func2str(objfun{i})) end end @@ -111,29 +99,21 @@ for i=1:length(objfun) if isequal(func2str(objfun{i}), 'powell2') if ~errorflag testFailed = testFailed+1; - if debug - dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i})) - end + dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i})) end if info~=3 testFailed = testFailed+1; - if debug - dprintf('Nonlinear solver is expected to fail on %s function with info==3 but did not the correct value of info.', func2str(objfun{i})) - end + dprintf('Nonlinear solver is expected to fail on %s function with info==3 but did not the correct value of info.', func2str(objfun{i})) end else if errorflag testFailed = testFailed+1; - if debug - dprintf('Nonlinear solver failed on %s function (info=%s).', func2str(objfun{i}), int2str(info)) - end + dprintf('Nonlinear solver failed on %s function (info=%s).', func2str(objfun{i}), int2str(info)) end end catch testFailed = testFailed+1; - if debug - dprintf('Nonlinear solver failed on %s function.', func2str(objfun{i})) - end + dprintf('Nonlinear solver failed on %s function.', func2str(objfun{i})) end end diff --git a/tests/riccatiupdate.m b/tests/riccatiupdate.m index 0cc04561a..f293c2fe0 100644 --- a/tests/riccatiupdate.m +++ b/tests/riccatiupdate.m @@ -1,5 +1,3 @@ -debug = true; - source_dir = getenv('source_root'); addpath([source_dir filesep 'matlab']); @@ -7,10 +5,8 @@ dynare_config; testFailed = 0; -if ~debug - skipline() - disp('*** TESTING: riccatiupdate.m ***'); -end +skipline() +disp('*** TESTING: riccatiupdate.m ***'); t0 = clock; @@ -57,28 +53,22 @@ try R = norm(Ptmp_fortran-Ptmp_matlab,1); if (R > tol) testFailed = testFailed+1; - if debug - dprintf('The Fortran Riccati update is wrong') - end + dprintf('The Fortran Riccati update is wrong') end catch testFailed = testFailed+1; - if debug - dprintf('Fortran Riccati update failed') - end + dprintf('Fortran Riccati update failed') end % Compare the Fortran and Matlab execution time -if debug - if tElapsed1