Mercurial > octave
changeset 26182:34617dd78f02
avoid possible leaked global variables in tests
* clearvars.m, bug-35448.tst, bug-50035.tst, bug-52722.tst,
bug-53027.tst, bug-53579.tst, bug-53599.tst, global.tst, io.tst,
nest/nest.tst, unwind.tst: Clear global variables at end of tests that
use them.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 07 Dec 2018 17:30:31 -0500 |
parents | d77938ba31c4 |
children | 341d927513dd |
files | scripts/miscellaneous/clearvars.m test/bug-35448/bug-35448.tst test/bug-50035/bug-50035.tst test/bug-52722/bug-52722.tst test/bug-53027/bug-53027.tst test/bug-53579.tst test/bug-53599.tst test/global.tst test/io.tst test/nest/nest.tst test/unwind.tst |
diffstat | 11 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/clearvars.m Sat Dec 08 12:49:39 2018 +0100 +++ b/scripts/miscellaneous/clearvars.m Fri Dec 07 17:30:31 2018 -0500 @@ -218,3 +218,6 @@ ## Test input validation %!error <'-global' must be the first option> clearvars ("ans", "-global") %!error <'-except' may only be specified once> clearvars ("-except", "-except") + +%!test +%! clear -global x y z; # cleanup after test
--- a/test/bug-35448/bug-35448.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/bug-35448/bug-35448.tst Fri Dec 07 17:30:31 2018 -0500 @@ -21,9 +21,11 @@ %! gfun = @fB; %! y = fA (e); %! assert (y, e); +%! clear -global gfun; # cleanup after test %!test %! global gfun %! gfun = @fC; %! y = fA (e); %! assert (y, e); +%! clear -global gfun; # cleanup after test
--- a/test/bug-50035/bug-50035.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/bug-50035/bug-50035.tst Fri Dec 07 17:30:31 2018 -0500 @@ -29,3 +29,4 @@ %! assert (in_name, "x"); %! bug50035 () %! assert (in_name, "ans"); +%! clear -global in_name; # cleanup after test
--- a/test/bug-52722/bug-52722.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/bug-52722/bug-52722.tst Fri Dec 07 17:30:31 2018 -0500 @@ -1,2 +1,3 @@ %!test %! include_globals +%! clear -global a b c; # cleanup after test
--- a/test/bug-53027/bug-53027.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/bug-53027/bug-53027.tst Fri Dec 07 17:30:31 2018 -0500 @@ -23,18 +23,22 @@ %! assert (X, 1); %! clear X %! assert (exist ("X"), 0); +%! clear -global X; # cleanup after test %!test <*53027> %! [a, b] = ntest53027a (); %! assert ([a, b], [0, 0]) +%! clear -global x; # cleanup after test %!test <*53027> %! [a, b] = ntest53027b (); %! assert ([a, b], [0, 0]) +%! clear -global x; # cleanup after test %!test <*53027> %! [a, b] = ntest53027c (); %! assert ([a, b], [0, 0]) +%! clear -global x; # cleanup after test ## Previous bugs have caused segfaults when executing script twice. %!test <*53027> @@ -48,3 +52,4 @@ %! assert (isglobal ("a") && isglobal ("c")) %! assert (! exist ("b")) %! assert (isempty (xx) && ! isglobal ("xx")) +%! clear -global a b c;
--- a/test/bug-53579.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/bug-53579.tst Fri Dec 07 17:30:31 2018 -0500 @@ -19,3 +19,4 @@ %! assert (igaa); %! assert (igbb); %! assert (xx, 5); +%! clear -global aa bb; # cleanup after test
--- a/test/bug-53599.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/bug-53599.tst Fri Dec 07 17:30:31 2018 -0500 @@ -21,3 +21,4 @@ %! global gval %! gval = 42; %! assert (sggval (), 42); +%! clear -global gval; # cleanup after test
--- a/test/global.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/global.tst Fri Dec 07 17:30:31 2018 -0500 @@ -19,6 +19,7 @@ %!test %! global G = 1; %! assert (G,1); +%! clear -global G; # cleanup after test %!function f () %! global G; @@ -27,6 +28,7 @@ %!test %! global G = 1; %! f; +%! clear -global G; # cleanup after test %!function f () %! fail ("G"); @@ -34,6 +36,7 @@ %!test %! global G = 1; %! f (); +%! clear -global G; # cleanup after test %!function f () %! global H = 1; @@ -41,6 +44,7 @@ %!test %! f; %! fail ("H"); +%! clear -global H; # cleanup after test %!function f () %! global H = 1; @@ -50,6 +54,7 @@ %! fail ("H"); %!test %! g (); +%! clear -global H; # cleanup after test %!function f () %! global H = 1; @@ -61,6 +66,7 @@ %!test %! f (); %! g (); +%! clear -global H; # cleanup after test %!test %!function f () @@ -68,6 +74,7 @@ %!endfunction %!test %! fail ("H"); +%! clear -global H; # cleanup after test %!function f () %! global H = 1; @@ -80,6 +87,7 @@ %! f; %! clear H; %! g; +%! clear -global H; # cleanup after test %!function r = f () %! x = 1; @@ -100,6 +108,7 @@ %! assert (f (), 1); %! global x %! assert (x, 1); +%! clear -global x; # cleanup after test %!function r = f () %! x = 1; @@ -120,6 +129,7 @@ %! assert (f (), 1); %! global x %! assert (x, 1); +%! clear -global x; # cleanup after test %!test %! warning ("off", "Octave:global-local-conflict", "local"); @@ -133,3 +143,4 @@ %! assert (x, 42); %! clear global x ## clears global and local value %! assert (exist ("x"), 0); +%! clear -global x; # cleanup after test
--- a/test/io.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/io.tst Fri Dec 07 17:30:31 2018 -0500 @@ -193,6 +193,7 @@ %! endfor %! %! assert (save_status && load_status); +%! clear -global a1; # cleanup after test %!testif HAVE_HDF5 %!
--- a/test/nest/nest.tst Sat Dec 08 12:49:39 2018 +0100 +++ b/test/nest/nest.tst Fri Dec 07 17:30:31 2018 -0500 @@ -22,7 +22,9 @@ ## It relies on the function files defined in the nest/ directory. ################################################################################ -%!assert (recursive_nest (), 25) +%!test +%! assert (recursive_nest (), 25) +%! clear -global recursive_nest_inc; # cleanup after test %!assert (recursive_nest2 (), 20)