# HG changeset patch # User Thorsten Meyer # Date 1231139530 -3600 # Node ID 34c0acf11539f597d1ccd1b842ac9096268a965b # Parent 502e58a0d44fb7b8ccdff0f2af7d88f5219eccda Fix error messages in __xzip__ diff -r 502e58a0d44f -r 34c0acf11539 scripts/ChangeLog --- a/scripts/ChangeLog Mon Jan 05 08:11:03 2009 +0100 +++ b/scripts/ChangeLog Mon Jan 05 08:12:10 2009 +0100 @@ -1,3 +1,7 @@ +2009-01-01 Thorsten Meyer + + * miscellaneous/__xzip__.m: Fix error messages, add tests. + 2008-12-26 Thorsten Meyer * general/int2str.m, general/num2str.m, strings/base2dec.m, diff -r 502e58a0d44f -r 34c0acf11539 scripts/miscellaneous/__xzip__.m --- a/scripts/miscellaneous/__xzip__.m Mon Jan 05 08:11:03 2009 +0100 +++ b/scripts/miscellaneous/__xzip__.m Mon Jan 05 08:12:10 2009 +0100 @@ -34,8 +34,7 @@ if (nargin == 4 || nargin == 5) if (! ischar (extension) || length (extension) == 0) - error (sprintf("%s: extension has to be a string with finite length", - commandname)); + error ("__xzip__: extension has to be a string with finite length"); endif if (nargin == 5 && ! exist (outdir, "dir")) @@ -83,15 +82,15 @@ ## FIXME this does not work when you try to compress directories compressed_files = cellfun(@(x) sprintf ("%s.%s", x, extension), - files, "UniformOutput", false); + files, "UniformOutput", false); endif if (nargout > 0) entries = compressed_files; endif else - error (sprintf("%s command failed with exit status = %d", - commandname, status)); + error ("%s command failed with exit status = %d", + commandname, status); endif unwind_protect_cleanup cd(cwd); @@ -119,3 +118,22 @@ d(idx) = ""; f(idx) = files(idx); endfunction + +%!error +%! __xzip__("gzip", "", "gzip -r %s", "bla"); +%!error +%! __xzip__("gzip", ".gz", "gzip -r %s", tmpnam); +%!error +%! # test __xzip__ with invalid compression command +%! unwind_protect +%! filename = tmpnam; +%! dummy = 1; +%! save(filename, "dummy"); +%! dirname = tmpnam; +%! mkdir(dirname); +%! entry = __xzip__("gzip", ".gz", "xxxzipxxx -r %s 2>/dev/null", +%! filename, dirname); +%! unwind_protect_cleanup +%! delete(filename); +%! rmdir(dirname); +%! end_unwind_protect