Mercurial > octave
changeset 28720:2c367a9c9660 stable
fix onCleanup in test files with multiple shared blocks (bug #59097)
* test.m: Also clear any existing shared variables at beginning of new
%!shared block.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 11 Sep 2020 18:36:27 -0400 |
parents | 45d958bc3437 |
children | 7ae10fadd008 a2177e663979 |
files | scripts/testfun/test.m |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/testfun/test.m Fri Sep 11 15:56:48 2020 -0400 +++ b/scripts/testfun/test.m Fri Sep 11 18:36:27 2020 -0400 @@ -406,6 +406,15 @@ __vars = __vars(1:__idx(1)-1); endif + if (! isempty (deblank (__shared))) + ## Explicitly clear any existing shared variables so that + ## onCleanup actions will be executed. + __shared_vars = strtrim (ostrsplit (__shared, ",")); + if (! isempty (__shared_vars)) + clear (__shared_vars{:}); + endif + endif + ## Assign default values to variables. try __vars = deblank (__vars); @@ -766,8 +775,8 @@ __file, sprintf (" %s", __leaked_vars{:})); endif - ## Clear any shared variables - ## This is necessary in case any onCleanup actions need to be triggered. + ## Explicitly clear any existing shared variables so that onCleanup + ## actions will be executed. __shared_vars = strtrim (ostrsplit (__shared, ",")); if (! isempty (__shared_vars)) clear (__shared_vars{:});