Mercurial > octave
changeset 22259:22f45a6b4693
Avoid displaying figures, ensure all figures are closed in BIST tests
* __osmesa_print__.cc: Wrap BIST tests in unwind_protect blocks, ensure figures
are closed and temporary files are deleted in cleanup section.
* material.m: Make figures created by %!error tests invisible, ensure figures
are closed.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Wed, 10 Aug 2016 18:28:39 -0700 |
parents | 553490ffc203 |
children | 93d475551be2 |
files | libinterp/dldfcn/__osmesa_print__.cc scripts/plot/appearance/material.m |
diffstat | 2 files changed, 71 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__osmesa_print__.cc Tue Aug 09 14:41:32 2016 +0200 +++ b/libinterp/dldfcn/__osmesa_print__.cc Wed Aug 10 18:28:39 2016 -0700 @@ -211,31 +211,39 @@ ## For the moment, disable these tests on PC's and Macs. %!testif HAVE_OPENGL, HAVE_OSMESA, HAVE_GL2PS_H %! if (isunix ()) -%! h = figure ("visible", "off"); +%! hf = figure ("visible", "off"); %! fn = tempname (); -%! sombrero (); -%! __osmesa_print__ (h, fn, "svg"); -%! assert (stat (fn).size, 2692270, -0.1); -%! unlink (fn); -%! img = __osmesa_print__ (h); -%! assert (size (img), [get(h, "position")([4, 3]), 3]); -%! ## Use pixel sum per RGB channel as fingerprint -%! img_fp = squeeze (sum (sum (img), 2)); -%! assert (img_fp, [52942515; 54167797; 56158178], -0.05); +%! unwind_protect +%! sombrero (); +%! __osmesa_print__ (hf, fn, "svg"); +%! assert (stat (fn).size, 2692270, -0.1); +%! img = __osmesa_print__ (hf); +%! assert (size (img), [get(hf, "position")([4, 3]), 3]); +%! ## Use pixel sum per RGB channel as fingerprint +%! img_fp = squeeze (sum (sum (img), 2)); +%! assert (img_fp, [52942515; 54167797; 56158178], -0.05); +%! unwind_protect_cleanup +%! close (hf); +%! unlink (fn); +%! end_unwind_protect %! endif %!testif HAVE_OPENGL, HAVE_OSMESA, HAVE_GL2PS_H %! if (isunix ()) -%! h = figure ("visible", "off"); +%! hf = figure ("visible", "off"); %! fn = tempname (); -%! plot (sin (0:0.1:2*pi)); -%! __osmesa_print__ (h, fn, "svgis2d"); -%! assert (stat (fn).size, 7438, -0.1); -%! unlink (fn); -%! img = __osmesa_print__ (h); -%! assert (size (img), [get(h, "position")([4, 3]), 3]); -%! ## Use pixel sum per RGB channel as fingerprint -%! img_fp = squeeze (sum (sum (img), 2)); -%! assert (img_fp, [59281711; 59281711; 59482179], -0.05); +%! unwind_protect +%! plot (sin (0:0.1:2*pi)); +%! __osmesa_print__ (hf, fn, "svgis2d"); +%! assert (stat (fn).size, 7438, -0.1); +%! img = __osmesa_print__ (hf); +%! assert (size (img), [get(hf, "position")([4, 3]), 3]); +%! ## Use pixel sum per RGB channel as fingerprint +%! img_fp = squeeze (sum (sum (img), 2)); +%! assert (img_fp, [59281711; 59281711; 59482179], -0.05); +%! unwind_protect_cleanup +%! close (hf); +%! unlink (fn); +%! end_unwind_protect %! endif */
--- a/scripts/plot/appearance/material.m Tue Aug 09 14:41:32 2016 +0200 +++ b/scripts/plot/appearance/material.m Wed Aug 10 18:28:39 2016 -0700 @@ -143,7 +143,7 @@ error ("material: unknown material type '%s'", mtype); endswitch - + if (nargout == 1) ## Return 1x5 cell vector with reflectance properties. retval = {as, ds, ss, se, scr}; @@ -296,13 +296,49 @@ %!error <Invalid call to material> a = material ({}) %!error <Invalid call to material> a = material ([.3 .4 .5]) %!error <Invalid call to material> [a, b] = material () -%!error <first argument must be a list of handles> material (-1, "metal") -%!error <unknown material type 'foo'> material foo -%!error <incorrect number of elements in material vector> material (-1) -%!error <incorrect number of elements in material vector> material ([1 2 3 4 5 6]) -%!error <MTYPE must be a named material or a vector> material ({}) + +## Test error handling, all following errors require a figure +%!error <first argument must be a list of handles> +%! hf = figure ("visible", "off"); +%! unwind_protect +%! material (-1, "metal") +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!error <unknown material type 'foo'> +%! hf = figure ("visible", "off"); +%! unwind_protect +%! material foo +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect -%!error <Invalid call to material.> +%!error <incorrect number of elements in material vector> +%! hf = figure ("visible", "off"); +%! unwind_protect +%! material (-1) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!error <incorrect number of elements in material vector> +%! hf = figure ("visible", "off"); +%! unwind_protect +%! material ([1 2 3 4 5 6]) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!error <MTYPE must be a named material or a vector> +%! hf = figure ("visible", "off"); +%! unwind_protect +%! material ({}) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!error <Invalid call to material.> %! hf = figure ("visible", "off"); %! unwind_protect %! material (hf);