annotate scripts/miscellaneous/tar.m @ 25231:e1024058833c stable

test: change remaining %!xtests into %!tests * tar.m, zip.m, fminsearch.m: Change %!xtest into %!test. Add or update FIXME comments in case tests fail on some systems. * clf.m, speed.m: Change %!xtest into %!test.
author Mike Miller <mtmiller@octave.org>
date Thu, 12 Apr 2018 12:09:14 -0700
parents 6652d3823428
children 00f796120a6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1 ## Copyright (C) 2005-2018 Søren Hauberg
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2 ##
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
3 ## This file is part of Octave.
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24096
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
6 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24096
diff changeset
7 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
8 ## (at your option) any later version.
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
9 ##
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## GNU General Public License for more details.
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents: 5808
diff changeset
14 ##
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6049
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24096
diff changeset
17 ## <https://www.gnu.org/licenses/>.
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
18
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20164
diff changeset
20 ## @deftypefn {} {@var{filelist} =} tar (@var{tarfile}, @var{files})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20164
diff changeset
21 ## @deftypefnx {} {@var{filelist} =} tar (@var{tarfile}, @var{files}, @var{rootdir})
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
22 ## Pack the list of files and directories specified in @var{files} into the
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
23 ## TAR archive @var{tarfile}.
5808
a18d85bdff31 [project @ 2006-05-11 03:11:03 by jwe]
jwe
parents: 5807
diff changeset
24 ##
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19951
diff changeset
25 ## @var{files} is a character array or cell array of strings. Shell wildcards
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19951
diff changeset
26 ## in the filename such as @samp{*} or @samp{?} are accepted and expanded.
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19951
diff changeset
27 ## Directories are recursively traversed and all files are added to the
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19951
diff changeset
28 ## archive.
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
29 ##
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
30 ## If @var{rootdir} is defined then any files without absolute pathnames are
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
31 ## located relative to @var{rootdir} rather than the current directory.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
32 ##
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
33 ## The optional output @var{filelist} is a list of the files that were included
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
34 ## in the archive.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
35 ## @seealso{untar, unpack, bzip2, gzip, zip}
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
36 ## @end deftypefn
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
37
17243
f4c8c66faf34 maint: Update source file encodings to UTF-8 and fix character errors
Mike Miller <mtmiller@ieee.org>
parents: 16724
diff changeset
38 ## Author: Søren Hauberg <hauberg@gmail.com>
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
39
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
40 function filelist = tar (tarfile, files, rootdir = ".")
5808
a18d85bdff31 [project @ 2006-05-11 03:11:03 by jwe]
jwe
parents: 5807
diff changeset
41
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
42 if (nargin < 2 || nargin > 3)
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
43 print_usage ();
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
44 endif
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
45
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
46 if (! ischar (tarfile))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
47 error ("tar: TARFILE must be a string");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
48 elseif (ischar (files))
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
49 files = cellstr (files);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
50 elseif (! iscellstr (files))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
51 error ("tar: FILES must be a character array or cellstr");
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
52 endif
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
53
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
54 rootdir = tilde_expand (rootdir);
5808
a18d85bdff31 [project @ 2006-05-11 03:11:03 by jwe]
jwe
parents: 5807
diff changeset
55
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
56 tarfile = make_absolute_filename (tarfile);
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19535
diff changeset
57
19951
8c20fb6caa16 Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
58 if (ispc)
8c20fb6caa16 Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
59 ## Change tarfile into a mingw style acceptable for tar
8c20fb6caa16 Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
60 tarfile = __w2mpth__ (tarfile);
8c20fb6caa16 Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
61 endif
8c20fb6caa16 Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
62
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
63 cmd = sprintf ("tar cvf %s -C %s %s",
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 tarfile, rootdir, sprintf (" %s", files{:}));
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
65
24096
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
66 ## Save and restore the TAR_OPTIONS environment variable used by GNU tar.
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
67 tar_options_env = getenv ("TAR_OPTIONS");
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
68 unwind_protect
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
69 unsetenv ("TAR_OPTIONS");
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
70 [status, output] = system (cmd);
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
71 unwind_protect_cleanup
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
72 if (! isempty (tar_options_env))
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
73 setenv ("TAR_OPTIONS", tar_options_env);
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
74 endif
8f3db1ac7877 tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents: 23220
diff changeset
75 end_unwind_protect
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
76
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
77 if (status)
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
78 error ("tar: tar exited with status = %d", status);
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
79 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
80
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
81 if (nargout > 0)
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19925
diff changeset
82 filelist = ostrsplit (output, "\r\n", true);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
83 filelist = filelist';
5808
a18d85bdff31 [project @ 2006-05-11 03:11:03 by jwe]
jwe
parents: 5807
diff changeset
84 endif
a18d85bdff31 [project @ 2006-05-11 03:11:03 by jwe]
jwe
parents: 5807
diff changeset
85
5807
29c4fb42b210 [project @ 2006-05-11 01:48:56 by jwe]
jwe
parents:
diff changeset
86 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17243
diff changeset
87
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
88
25231
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
89 ## FIXME: This test may fail if the tar command is not installed. If this
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
90 ## test fails, it might be better to change it into a testif with a
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
91 ## runtime condition on the tar program.
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
92 %!test
19925
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
93 %! ## test tar together with untar
19535
827cc33ae05c avoid warning message in test for tar function
John W. Eaton <jwe@octave.org>
parents: 19258
diff changeset
94 %! orig_dir = pwd ();
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
95 %! unwind_protect
19925
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
96 %! dirname = tarname = outdir = "";
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
97 %! dirname = tempname ();
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
98 %! assert (mkdir (dirname));
19535
827cc33ae05c avoid warning message in test for tar function
John W. Eaton <jwe@octave.org>
parents: 19258
diff changeset
99 %! chdir (dirname);
827cc33ae05c avoid warning message in test for tar function
John W. Eaton <jwe@octave.org>
parents: 19258
diff changeset
100 %! dirname2 = "dir2";
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
101 %! assert (mkdir (dirname2));
19925
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
102 %! fname1 = "file1";
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
103 %! fname2 = fullfile (dirname2, "file2");
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
104 %! fid = fopen (fname1, "wt");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
105 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
106 %! fdisp (fid, "Hello World");
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19535
diff changeset
107 %! fclose (fid);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
108 %! fid = fopen (fname2, "wt");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
109 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
110 %! fdisp (fid, "Goodbye World");
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19535
diff changeset
111 %! fclose (fid);
19925
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
112 %! tarname = [tempname() ".tar"];
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
113 %! filelist = tar (tarname, {dirname2, fname1});
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
114 %! if (! strcmp (filelist{3}, fname1))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
115 %! error ("tar file contents does not match expected file");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
116 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
117 %! if (! exist (tarname, "file"))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
118 %! error ("tar archive file cannot be found!");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
119 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
120 %! outdir = tempname;
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
121 %! untar (tarname, outdir);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
122 %! fid = fopen (fullfile (outdir, fname1), "rt");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
123 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
124 %! str = fgetl (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
125 %! fclose (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
126 %! assert (str, "Hello World");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
127 %! fid = fopen (fullfile (outdir, fname2), "rt");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
128 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
129 %! str = fgetl (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
130 %! fclose (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
131 %! assert (str, "Goodbye World");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
132 %! unwind_protect_cleanup
19925
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
133 %! chdir (orig_dir);
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19925
diff changeset
134 %! unlink (tarname);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
135 %! confirm_recursive_rmdir (false, "local");
19925
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
136 %! if (exist (dirname))
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
137 %! rmdir (dirname, "s");
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
138 %! endif
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
139 %! if (exist (outdir))
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
140 %! rmdir (outdir, "s");
ee7159d9a330 tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents: 19697
diff changeset
141 %! endif
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
142 %! end_unwind_protect
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
143
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
144 ## Test input validation
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
145 %!error tar ()
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
146 %!error tar (1)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
147 %!error tar (1,2,3,4)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
148 %!error <TARFILE must be a string> tar (1, "foobar")
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
149 %!error <FILES must be a character array or cellstr> tar ("foobar", 1)