changeset 25142:ca20eb3d0535

ensure pkg tests do not write any files to user's home directory (bug #53557) * pkg.tst: Change pkg local_list to a temporary file. Use onCleanup object to restore pkg local_list when tests are complete.
author Mike Miller <mtmiller@octave.org>
date Fri, 06 Apr 2018 13:37:32 -0700
parents c7de02b5b227
children 33bb7ffc54a1
files test/pkg/pkg.tst
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/pkg/pkg.tst	Fri Apr 06 13:34:03 2018 -0700
+++ b/test/pkg/pkg.tst	Fri Apr 06 13:37:32 2018 -0700
@@ -22,11 +22,13 @@
 ## All actions should be tested, and ideally all options are tested.
 ############################################################
 
-%!shared old_prefix, old_archprefix, prefix, restorecfg, rmtmpdir, mfile_pkg_name, mfile_pkg_zip
+%!shared old_prefix, old_archprefix, old_local_list, prefix, restorecfg, restorecache, rmtmpdir, mfile_pkg_name, mfile_pkg_zip
 %!
 %! ## 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));
 %! prefix = tempname ();
 %! [status] = mkdir (prefix);
 %! if (! status)
@@ -34,6 +36,7 @@
 %!   return;  # abort further testing
 %! endif
 %! pkg ("prefix", prefix, prefix);
+%! pkg ("local_list", fullfile (prefix, "octave_packages"));
 %! rmtmpdir = @onCleanup (@() confirm_recursive_rmdir (0, "local") && rmdir (prefix, "s"));
 %!
 %! ## Create zip file packages of testing directories in prefix directory