Mercurial > octave-libtiff
view test/pkg/pkg.tst @ 28087:9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
* dirfns.cc (Frmdir): Change DEFMETHODX macro invocation to include nargout variable.
Check nargout, and for cases where "nargout == 0" and "status" indicates failure,
throw an error. For cases where "nargout > 0", return 3-value octave_value_list
in variable "retval".
* file-io.cc, gzip.cc, dir.m, isfolder.m, mkdir.m, run.m, tar.m,
unpack.m, zip.m, pathdef.m, savepath.m, configure_make.m, install.m,
uninstall.m, getpref.m, setpref.m, pkg.tst, publish.tst, system.tst:
Change calls from "rmdir" to "sts = rmdir" so that an error is not
unecessarily thrown in BIST tests and other clean up code.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 17 Feb 2020 20:02:18 -0800 |
parents | bd51beb6205e |
children | 11f1207111c5 |
line wrap: on
line source
######################################################################## ## ## Copyright (C) 2018-2020 The Octave Project Developers ## ## See the file COPYRIGHT.md in the top-level directory of this ## distribution or <https://octave.org/copyright/>. ## ## This file is part of Octave. ## ## Octave is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## <https://www.gnu.org/licenses/>. ## ######################################################################## ############################################################ ## Test suite for pkg.m ## Tests are organized first by action, and then by options. ## All actions should be tested, and ideally all options are tested. ############################################################ %!shared old_prefix, old_archprefix, old_local_list, old_global_list, prefix, restorecfg, restorecache, restoreglobalcache, rmtmpdir, mfile_pkg_name, mfile_pkg_tgz %!function test_cleanup (prefix) %! confirm_recursive_rmdir (0, "local"); %! sts = rmdir (prefix, "s"); %!endfunction %!testif HAVE_Z %! ## Do all tests in a temporary directory %! [old_prefix, old_archprefix] = pkg ("prefix"); %! restorecfg = onCleanup (@() pkg ("prefix", old_prefix, old_archprefix)); %! old_local_list = pkg ("local_list"); %! restorecache = onCleanup (@() pkg ("local_list", old_local_list)); %! old_global_list = pkg ("global_list"); %! restoreglobalcache = onCleanup (@() pkg ("global_list", old_global_list)); %! prefix = tempname (); %! [status] = mkdir (prefix); %! if (! status) %! error ("pkg.tst: Could not create temporary directory for pkg testing"); %! return; # abort further testing %! endif %! pkg ("prefix", prefix, prefix); %! pkg ("local_list", fullfile (prefix, "octave_packages")); %! pkg ("global_list", fullfile (prefix, "octave_packages")); %! rmtmpdir = @onCleanup (@() test_cleanup (prefix)); %! %! ## Create tar.gz file packages of testing directories in prefix directory %! mfile_pkg_name = {"mfile_basic_test", "mfile_minimal_test"}; %! mfile_pkg_tar = fullfile (prefix, strcat (mfile_pkg_name, ".tar")); %! mfile_pkg_tgz = strcat (mfile_pkg_tar, ".gz"); %! for i = 1:numel (mfile_pkg_name) %! tar (mfile_pkg_tar{i}, mfile_pkg_name{i}); %! gzip (mfile_pkg_tar{i}); %! endfor ## Avoids printing to stdout when installing %!function silent_pkg_install (varargin) %! evalc (["pkg install", sprintf(" %s", varargin{:})]); %!endfunction ## Action install/uninstall %!testif HAVE_Z %! for i = 1:numel (mfile_pkg_name) %! silent_pkg_install (mfile_pkg_tgz{i}); %! system (["chmod -Rf u+w '" prefix "'"]); ## FIXME: Work around bug #53578 %! pkg ("uninstall", mfile_pkg_name{i}); %! endfor %! %!error pkg ("install", "nonexistent.zip") # -local %!testif HAVE_Z %! for i = 1:numel (mfile_pkg_name) %! silent_pkg_install ("-local", mfile_pkg_tgz{i}); %! system (["chmod -Rf u+w '" prefix "'"]); ## FIXME: Work around bug #53578 %! pkg ("uninstall", mfile_pkg_name{i}); %! endfor # -forge (need check for options?) ## FIXME: Need test # We do not test this yet ... fails if no internet connection # use dataframe which is an mfile only package #%!test #%! silent_pkg_install ("-forge", "dataframe"); #%! pkg ("uninstall", "dataframe"); # -nodeps ## FIXME: Need test # -verbose ## FIXME: Need test ## Action load/unload (within install/uninstall) %!testif HAVE_Z %! save_default_options ("-binary", "local"); %! for i = 1:numel (mfile_pkg_name) %! name = mfile_pkg_name{i}; %! silent_pkg_install ("-local", mfile_pkg_tgz{i}); %! unwind_protect %! pkg ("load", name); %! pkg ("unload", name); %! unwind_protect_cleanup %! system (["chmod -Rf u+w '" prefix "'"]); ## FIXME: Work around bug #53578 %! pkg ("uninstall", name); %! end_unwind_protect %! endfor %! %!error <package foobar is not installed> pkg ("load", "foobar"); # -nodeps ## FIXME: Need test # -verbose ## FIXME: Need test ## Action list %!test %! [user_packages, system_packages] = pkg ("list"); # -forge #%!test #%! oct_forge_pkgs = pkg ("list", "-forge"); ## Action describe %!testif HAVE_Z %! silent_pkg_install ("-local", mfile_pkg_tgz{1}); %! [desc, flag] = pkg ("describe", mfile_pkg_name{1}); %! ## FIXME: this only tests that the describe command runs, %! ## not that the output is in anyway correct. %! system (["chmod -Rf u+w '" prefix "'"]); ## FIXME: Work around bug #53578 %! pkg ("uninstall", mfile_pkg_name{1}); # -verbose ## FIXME: Need test ## Action prefix %!test %! pfx_old = pkg ("prefix"); %! unwind_protect %! pfx_new = pkg ("prefix", pwd ()); %! assert (pfx_new, pwd ()); %! unwind_protect_cleanup %! pfx = pkg ("prefix", pfx_old); %! end_unwind_protect ## Action build ## FIXME: Need test # pkg build -verbose /tmp image-* ## Action rebuild ## FIXME: Need test # pkg rebuild signal ## Future commands %!error pkg ("whereis", "myfunc.m") %!error pkg ("whereis", "-forge", "myfunc.m") ############################################################ ## End of Tests ############################################################