Skip to content

Commit 72742d8

Browse files
committed
test: Skip tests for save file format "-v7" when built without zlib (bug #45833).
* test/classdef-load-save/classdef-load-save-v7.tst: Make all tests conditional on whether Octave was built with zlib.
1 parent 73918fa commit 72742d8

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

test/classdef-load-save/classdef-load-save-v7.tst

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
########################################################################
2525

2626
## No constructor, ConstructOnLoad = false, no loadobj/saveobj
27-
%!test
27+
%!testif HAVE_ZLIB
2828
%! obj = regular_class ();
2929
%! obj.a = 1;
3030
%! obj.b = "Regular Class";
@@ -47,7 +47,7 @@
4747

4848
## Constructor defined, ConstructOnLoad = false, no loadobj/saveobj
4949
## (ensures that constructor is NOT called on load)
50-
%!test
50+
%!testif HAVE_ZLIB
5151
%! obj = regular_class_with_constructor ();
5252
%! obj.a = [];
5353
%! savefile = tempname ();
@@ -61,7 +61,7 @@
6161
%! end_unwind_protect
6262

6363
## No constructor, ConstructOnLoad = false, no loadobj/saveobj, nested object
64-
%!test
64+
%!testif HAVE_ZLIB
6565
%! obj = regular_class ();
6666
%! obj.a = regular_class_with_constructor ();
6767
%! savefile = tempname ();
@@ -76,7 +76,7 @@
7676
%! end_unwind_protect
7777

7878
## No constructor, ConstructOnLoad = false, no loadobj/saveobj, nested object inside a struct
79-
%!test <45833>
79+
%!testif HAVE_ZLIB <45833>
8080
%! obj = regular_class ();
8181
%! s.obj_field = regular_class_with_constructor ();
8282
%! obj.a = s;
@@ -91,7 +91,7 @@
9191
%! end_unwind_protect
9292

9393
## Vector of value class objects.
94-
%!test
94+
%!testif HAVE_ZLIB
9595
%! obj = regular_class;
9696
%! obj.a = 1;
9797
%! obj(2) = regular_class;
@@ -108,7 +108,7 @@
108108
%! end_unwind_protect
109109

110110
## Matrix of value class objects.
111-
%!test <*65179>
111+
%!testif HAVE_ZLIB <*65179>
112112
%! obj = regular_class;
113113
%! obj.a = 1;
114114
%! obj(2,3) = regular_class;
@@ -126,7 +126,7 @@
126126
%! end_unwind_protect
127127

128128
## No constructor, ConstructOnLoad = false, saveobj returns an object, no loadobj
129-
%!test
129+
%!testif HAVE_ZLIB
130130
%! obj = saveobj_obj_class ();
131131
%! obj.a = 1;
132132
%! obj.b = 3;
@@ -143,7 +143,7 @@
143143
%! end_unwind_protect
144144

145145
## No constructor, ConstructOnLoad = false, saveobj returns a struct, no loadobj
146-
%!test
146+
%!testif HAVE_ZLIB
147147
%! obj = saveobj_struct_class ();
148148
%! obj.a = 1;
149149
%! savefile = tempname ();
@@ -158,7 +158,7 @@
158158
%! end_unwind_protect
159159

160160
## No constructor, ConstructOnLoad = false, loadobj is defined, no saveobj
161-
%!test
161+
%!testif HAVE_ZLIB
162162
%! obj = loadobj_class ();
163163
%! obj.a = 1;
164164
%! savefile = tempname ();
@@ -173,7 +173,7 @@
173173

174174
## No constructor, ConstructOnLoad = false, loadobj is defined, no saveobj
175175
## Class definition changes between saving and loading the object
176-
%!test <67414>
176+
%!testif HAVE_ZLIB <67414>
177177
%! clear classes;
178178
%! obj = loadobj_changed_class ();
179179
%! obj.a = 0;
@@ -199,7 +199,7 @@
199199
%! end_unwind_protect
200200

201201
## No constructor, ConstructOnLoad = false, loadobj is defined, saveobj is defined
202-
%!test
202+
%!testif HAVE_ZLIB
203203
%! obj = loadobj_saveobj_class ();
204204
%! obj.a = 1;
205205
%! savefile = tempname ();
@@ -213,7 +213,7 @@
213213
%! end_unwind_protect
214214

215215
## Constructor defined, ConstructOnLoad = false, custom return type for loadobj/saveobj
216-
%!test
216+
%!testif HAVE_ZLIB
217217
%! obj = custom_saveobj ();
218218
%! savefile = tempname ();
219219
%! save ('-v7', savefile, 'obj');
@@ -226,7 +226,7 @@
226226
%! end_unwind_protect
227227

228228
## No constructor, ConstructOnLoad = false, undefined return variable from saveobj (should return default initialized classdef)
229-
%!test
229+
%!testif HAVE_ZLIB
230230
%! obj = invalid_saveobj_class ();
231231
%! obj.a = 1;
232232
%! savefile = tempname ();
@@ -240,15 +240,20 @@
240240
%! end_unwind_protect
241241

242242
## No constructor, ConstructOnLoad = false, undefined return variable from saveobj (should emit a warning)
243-
%!warning <saveobj.*does not return.*value>
243+
%!testif HAVE_ZLIB
244244
%! obj = invalid_saveobj_class ();
245245
%! obj.a = 1;
246246
%! savefile = tempname ();
247-
%! save ('-v7', savefile, 'obj');
248-
%! delete (savefile);
247+
%! lastwarn ("");
248+
%! unwind_protect
249+
%! save ('-v7', savefile, 'obj');
250+
%! assert (! isempty (regexp (lastwarn (), "saveobj.*does not return.*value", "once")));
251+
%! unwind_protect_cleanup
252+
%! delete (savefile);
253+
%! end_unwind_protect
249254

250255
## Handle class, no constructor, ConstructOnLoad = false, no loadobj/saveobj
251-
%!test
256+
%!testif HAVE_ZLIB
252257
%! obj1 = regular_handle_class ();
253258
%! obj2 = obj1;
254259
%! obj2.a = 1;
@@ -264,7 +269,7 @@
264269
%! end_unwind_protect
265270

266271
## Handle class, no constructor, ConstructOnLoad = false, no loadobj/saveobj, circular references
267-
%!test
272+
%!testif HAVE_ZLIB
268273
%! obj = regular_handle_class ();
269274
%! obj.a = regular_handle_class ();
270275
%! obj.c = 1;
@@ -286,7 +291,7 @@
286291
%! end_unwind_protect
287292

288293
## Handle class, no constructor, ConstructOnLoad = false, no loadobj/saveobj, vector
289-
%!test
294+
%!testif HAVE_ZLIB
290295
%! obj = regular_handle_class ();
291296
%! obj(2) = regular_handle_class ();
292297
%! obj(3) = obj(1);
@@ -306,7 +311,7 @@
306311
%! end_unwind_protect
307312

308313
## Constructor, ConstructOnLoad = false, Transient property
309-
%!test
314+
%!testif HAVE_ZLIB
310315
%! obj = transient_property_class ();
311316
%! obj.a = 1;
312317
%! obj.transient_property = 6;
@@ -323,7 +328,7 @@
323328
%! end_unwind_protect
324329

325330
## Constructor, ConstructOnLoad = true, Transient property, no loadobj/saveobj
326-
%!test
331+
%!testif HAVE_ZLIB
327332
%! obj = regular_class_construct_on_load ();
328333
%! obj.a = 10;
329334
%! obj.f = 16;

0 commit comments

Comments
 (0)