diff --git a/tests/run_block_byte_tests_matlab.m b/tests/run_block_byte_tests_matlab.m index de922c0322c00c5be7f446d787fa69d6250db173..f7d55899b8ea5fc6a1dbac5d8d80a195f619fbb9 100644 --- a/tests/run_block_byte_tests_matlab.m +++ b/tests/run_block_byte_tests_matlab.m @@ -19,9 +19,13 @@ % % Before every call to Dynare, the contents of the workspace is saved in % 'wsMat.mat', and reloaded after Dynare has finished (this is necessary since -% Dynare does a 'clear -all'). Also note that we take care of clearing the -% 'exception' variable in all 'catch' block, because otherwise the next 'load -% wsMat' within a 'catch' block will overwrite the last exception. +% Dynare does a 'clear -all'). +% Note that we take care of clearing oo_ before saving the workspace, +% otherwise the newly created oo_ will be scratched upon loading, +% thus making the path comparison bogus. +% We also take care of clearing the 'exception' variable in all 'catch' +% block, because otherwise the next 'load wsMat' within a 'catch' block will +% overwrite the last exception. top_test_dir = getenv('TOP_TEST_DIR'); addpath([top_test_dir filesep 'utils']); @@ -80,6 +84,7 @@ for blockFlag = 0:1 else try old_path = path; + clear oo_ % Ensure that oo_.endo_simul won’t be overwritten when loading wsMat save wsMat run_ls2003(blockFlag, storageFlag, solve_algos(i), default_stack_solve_algo) load wsMat @@ -87,9 +92,9 @@ for blockFlag = 0:1 % Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; - if abs(diff) > options_.dynatol.x + if max(max(abs(diff))) > options_.dynatol.x failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')']; - exception = MException('ERROR: simulation path differs from the reference path'); + exception = MException('Dynare:simerr', 'ERROR: simulation path differs from the reference path'); printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception); clear exception end @@ -106,6 +111,7 @@ for blockFlag = 0:1 num_block_tests = num_block_tests + 1; try old_path = path; + clear oo_ % Ensure that oo_.endo_simul won’t be overwritten when loading wsMat save wsMat run_ls2003(blockFlag, storageFlag, default_solve_algo, stack_solve_algos(i)) load wsMat @@ -113,9 +119,9 @@ for blockFlag = 0:1 % Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; - if abs(diff) > options_.dynatol.x + if max(max(abs(diff))) > options_.dynatol.x failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')']; - exception = MException('ERROR: simulation path difers from the reference path'); + exception = MException('Dynare:simerr', 'ERROR: simulation path difers from the reference path'); printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], exception); clear exception end diff --git a/tests/run_block_byte_tests_octave.m b/tests/run_block_byte_tests_octave.m index b6319ca272b9b930165a9d77b3a6c863c325ccc5..ce30c1be45465807c3849e5a4624b87933370e85 100644 --- a/tests/run_block_byte_tests_octave.m +++ b/tests/run_block_byte_tests_octave.m @@ -20,6 +20,9 @@ ## Before every call to Dynare, the contents of the workspace is saved in ## 'wsOct', and reloaded after Dynare has finished (this is necessary since ## Dynare does a 'clear -all'). +## Note that we take care of clearing oo_ before saving the workspace, +## otherwise the newly created oo_ will be scratched upon loading, +## thus making the path comparison bogus. top_test_dir = getenv('TOP_TEST_DIR'); addpath([top_test_dir filesep 'utils']); @@ -58,7 +61,7 @@ for blockFlag = 0:1 # Workaround for strange race condition related to the static/dynamic # files (especially when we switch to/from use_dll) - rmdir('+ls2003_tmp', 's') + rmdir('+ls2003_tmp', 's'); pause(1) for i = 1:length(solve_algos) @@ -83,6 +86,7 @@ for blockFlag = 0:1 else try old_path = path; + clear oo_ # Ensure that oo_.endo_simul won’t be overwritten when loading wsOct save wsOct run_ls2003(blockFlag, storageFlag, solve_algos(i), default_stack_solve_algo) load wsOct @@ -90,7 +94,7 @@ for blockFlag = 0:1 ## Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; - if abs(diff) > options_.dynatol.x + if max(max(abs(diff))) > options_.dynatol.x failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')']; differr.message = ["ERROR: simulation path differs from the reference path" ]; printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], differr); @@ -107,6 +111,7 @@ for blockFlag = 0:1 num_block_tests = num_block_tests + 1; try old_path = path; + clear oo_ # Ensure that oo_.endo_simul won’t be overwritten when loading wsOct save wsOct run_ls2003(blockFlag, storageFlag, default_solve_algo, stack_solve_algos(i)) load wsOct @@ -114,7 +119,7 @@ for blockFlag = 0:1 ## Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; - if abs(diff) > options_.dynatol.x + if max(max(abs(diff))) > options_.dynatol.x failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')']; differr.message = ["ERROR: simulation path differs from the reference path" ]; printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], differr);