Mercurial > octave
changeset 33581:afbff609c241 stable
test: Try to clean up also in case test failed (bug #53027).
* test/bug-53027/bug-53027.tst: Use unwind_protect blocks to ensure cleanup runs
also if tests failed.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 13 May 2024 18:05:26 +0200 |
parents | aa773ddbe25b |
children | de14d508b8f9 87365d404184 |
files | test/bug-53027/bug-53027.tst |
diffstat | 1 files changed, 42 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/test/bug-53027/bug-53027.tst Sat May 11 14:48:34 2024 +0200 +++ b/test/bug-53027/bug-53027.tst Mon May 13 18:05:26 2024 +0200 @@ -15,42 +15,57 @@ %! global X; %! X = 0; %! fname = tempname (); -%! save53027 (fname); -%! assert (X, 1); -%! load53027 (fname); -%! assert (X, 1); -%! load53027 (fname); -%! assert (X, 1); -%! clear X -%! assert (exist ("X"), 0); -%! clear -global X; # cleanup after test -%! unlink (fname); # remove temp file +%! unwind_protect +%! save53027 (fname); +%! assert (X, 1); +%! load53027 (fname); +%! assert (X, 1); +%! load53027 (fname); +%! assert (X, 1); +%! clear X +%! assert (exist ("X"), 0); +%! unwind_protect_cleanup +%! clear -global X; +%! unlink (fname); # remove temp file +%! end_unwind_protect %!test <*53027> %! [a, b] = ntest53027a (); -%! assert ([a, b], [0, 0]) -%! clear -global x; # cleanup after test +%! unwind_protect +%! assert ([a, b], [0, 0]) +%! unwind_protect_cleanup +%! clear -global x; +%! end_unwind_protect %!test <*53027> %! [a, b] = ntest53027b (); -%! assert ([a, b], [0, 0]) -%! clear -global x; # cleanup after test +%! unwind_protect +%! assert ([a, b], [0, 0]) +%! unwind_protect_cleanup +%! clear -global x; +%! end_unwind_protect %!test <*53027> %! [a, b] = ntest53027c (); -%! assert ([a, b], [0, 0]) -%! clear -global x; # cleanup after test +%! unwind_protect +%! assert ([a, b], [0, 0]) +%! unwind_protect_cleanup +%! clear -global x; +%! end_unwind_protect ## Previous bugs have caused segfaults when executing script twice. %!test <*53027> -%! gtest53027 -%! assert (isempty (a) && isempty (c)) -%! assert (isglobal ("a") && isglobal ("c")) -%! assert (! exist ("b")) -%! assert (isempty (xx) && ! isglobal ("xx")) -%! gtest53027 -%! assert (isempty (a) && isempty (c)) -%! assert (isglobal ("a") && isglobal ("c")) -%! assert (! exist ("b")) -%! assert (isempty (xx) && ! isglobal ("xx")) -%! clear -global a b c; +%! unwind_protect +%! gtest53027 +%! assert (isempty (a) && isempty (c)) +%! assert (isglobal ("a") && isglobal ("c")) +%! assert (! exist ("b")) +%! assert (isempty (xx) && ! isglobal ("xx")) +%! gtest53027 +%! assert (isempty (a) && isempty (c)) +%! assert (isglobal ("a") && isglobal ("c")) +%! assert (! exist ("b")) +%! assert (isempty (xx) && ! isglobal ("xx")) +%! unwind_protect_cleanup +%! clear -global a b c; +%! end_unwind_protect