changeset 28721:7ae10fadd008

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Fri, 11 Sep 2020 18:57:59 -0400
parents 3211325aa1bf (current diff) 2c367a9c9660 (diff)
children 08049eff8733
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 16:01:03 2020 -0400
+++ b/scripts/testfun/test.m	Fri Sep 11 18:57:59 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{:});