changeset 27361:a7d21a6a7922 stable

BIST should not rely on the current directory to be writable. * libinterp/corefcn/help.cc: Change to "tempdir" before executing the test to ensure a writable directory. Change to previous directory on cleanup. Determine the function name using "fileparts" rather than hard coded truncation. * libinterp/corefcn/variables.cc: Change to "tempdir" before executing the test to ensure a writable directory. Change to previous directory on cleanup. Two tests in the modified files are failing in a Linux distribution installed version of GNU Octave when running "__run_test_suite__". "__run_test_suite__" changes the current directory "pwd" to those owned by root usually, e.g. "/usr/share/...". Therefore, a non-root Octave session is not able to create files in those directories. These errors do not occur, if the test suite directory is owned by the user of the octave session or the test file is called directly from some writeable directory. Which is usually the case for custom or development builds.
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Sat, 31 Aug 2019 15:00:42 +0900
parents 60bb69799591
children 682695bd0e98 d9d10a49926d
files libinterp/corefcn/help.cc libinterp/corefcn/variables.cc
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc	Thu Aug 29 17:17:13 2019 +0900
+++ b/libinterp/corefcn/help.cc	Sat Aug 31 15:00:42 2019 +0900
@@ -841,8 +841,9 @@
 
 /*
 %!test
+%! old_dir = cd (tempdir ());
 %! f = tempname (".", "oct_");
-%! fcn_name = f(3:end);
+%! [~, fcn_name] = fileparts (f);
 %! f = [f ".m"];
 %! unwind_protect
 %!   fid = fopen (f, "w+");
@@ -856,6 +857,7 @@
 %!   assert (d{2} (3), 6);
 %! unwind_protect_cleanup
 %!   unlink (f);
+%!   cd (old_dir);
 %! end_unwind_protect
 */
 
--- a/libinterp/corefcn/variables.cc	Thu Aug 29 17:17:13 2019 +0900
+++ b/libinterp/corefcn/variables.cc	Sat Aug 31 15:00:42 2019 +0900
@@ -486,6 +486,7 @@
 
 ## Don't search path for absolute filenames
 %!test
+%! old_dir = cd (tempdir ());
 %! tname = tempname (pwd ());
 %! unwind_protect
 %!   ## open/close file to create it, equivalent of touch
@@ -495,6 +496,7 @@
 %!   assert (exist (fullfile (pwd (), fname), "file"), 2);
 %! unwind_protect_cleanup
 %!   unlink (tname);
+%!   cd (old_dir);
 %! end_unwind_protect
 %! assert (exist (fullfile (pwd (), "%nonexistentfile%"), "file"), 0);