From a98393339b8d7c7f3bf5ddbb9f3990a3261d8b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 17 Nov 2011 11:52:18 +0100 Subject: [PATCH] Testsuite: better isolation between tests Restore the path and add an extra clear all between tests --- tests/run_test_matlab.m | 20 ++++++++++++++++++++ tests/run_test_octave.m | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/tests/run_test_matlab.m b/tests/run_test_matlab.m index 6a9cdedd7..a5713788c 100644 --- a/tests/run_test_matlab.m +++ b/tests/run_test_matlab.m @@ -46,11 +46,16 @@ while ~isempty(name) disp(''); disp(['*** TESTING: ' modfile ' ***']); try + old_path = path; save wsMat dynare([testfile ext],'console') + clear -all load wsMat + path(old_path); catch exception + clear -all load wsMat + path(old_path); failedBase{size(failedBase,2)+1} = modfile; printMakeCheckMatlabErrMsg(modfile, exception); clear exception @@ -90,22 +95,30 @@ for blockFlag = 0:1 % This is the reference simulation path against which all % other simulations will be tested try + old_path = path; save wsMat run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo) + clear -all load wsMat + path(old_path); y_ref = oo_.endo_simul; save('test.mat','y_ref'); catch exception + clear -all load wsMat + path(old_path); failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], exception); clear exception end else try + old_path = path; save wsMat run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo) + clear -all load wsMat + path(old_path); % Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; @@ -116,7 +129,9 @@ for blockFlag = 0:1 clear exception end catch exception + clear -all load wsMat + path(old_path); failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], exception); clear exception @@ -126,9 +141,12 @@ for blockFlag = 0:1 for i = 1:length(stack_solve_algos) num_block_tests = num_block_tests + 1; try + old_path = path; save wsMat run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i)) + clear -all load wsMat + path(old_path); % Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; @@ -139,7 +157,9 @@ for blockFlag = 0:1 clear exception end catch exception + clear -all load wsMat + path(old_path); failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], exception); clear exception diff --git a/tests/run_test_octave.m b/tests/run_test_octave.m index 5f7bb9654..03c6ad7be 100644 --- a/tests/run_test_octave.m +++ b/tests/run_test_octave.m @@ -45,11 +45,16 @@ for i=1:size(name,2) cd(directory); printf("\n*** TESTING: %s ***\n", name{i}); try + old_path = path; save wsOct dynare([testfile ext]) + clear -all load wsOct + path(old_path); catch + clear -all load wsOct + path(old_path); failedBase{size(failedBase,2)+1} = name{i}; printMakeCheckOctaveErrMsg(name{i}, lasterror); end_try_catch @@ -85,21 +90,29 @@ for blockFlag = 0:1 ## This is the reference simulation path against which all ## other simulations will be tested try + old_path = path; save wsOct run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo) + clear -all load wsOct + path(old_path); y_ref = oo_.endo_simul; save('test.mat','y_ref'); catch + clear -all load wsOct + path(old_path); failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror); end_try_catch else try + old_path = path; save wsOct run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo) + clear -all load wsOct + path(old_path); ## Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; @@ -109,7 +122,9 @@ for blockFlag = 0:1 printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], differr); endif catch + clear -all load wsOct + path(old_path); failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror); end_try_catch @@ -118,9 +133,12 @@ for blockFlag = 0:1 for i = 1:length(stack_solve_algos) num_block_tests = num_block_tests + 1; try + old_path = path; save wsOct run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i)) + clear -all load wsOct + path(old_path); ## Test against the reference simulation path load('test.mat','y_ref'); diff = oo_.endo_simul - y_ref; @@ -130,7 +148,9 @@ for blockFlag = 0:1 printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'], differr); endif catch + clear -all load wsOct + path(old_path); failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')']; printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror); end_try_catch