diff libinterp/corefcn/help.cc @ 26677:33f79d94f21f

Create any BIST temporary files in writable temporary directory (bug #55565). * help.cc: Call tempname with DIR argument of P_tmpdir to generate a name in temporary directory. Save PATH variable before unwind_protect. Use addpath() to put P_tmpdir on PATH variable for length of BIST test. Use path() in unwind_protect_cleanup to restore the PATH variable. * variables.cc (Fexist): Call tempname() without argument so that name is created in P_tmpdir() directory.
author Rik <rik@octave.org>
date Mon, 04 Feb 2019 13:47:15 -0800
parents cf9e10ce3351
children 2b6aa96a5c82
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc	Mon Feb 04 18:27:12 2019 +0000
+++ b/libinterp/corefcn/help.cc	Mon Feb 04 13:47:15 2019 -0800
@@ -841,10 +841,12 @@
 
 /*
 %!test
-%! f = tempname (".", "oct_");
-%! fcn_name = f(3:end);
+%! f = tempname (P_tmpdir, "oct_");
+%! [~, fcn_name] = fileparts (f);
 %! f = [f ".m"];
+%! save_path = path ();
 %! unwind_protect
+%!   addpath (P_tmpdir);
 %!   fid = fopen (f, "w+");
 %!   fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name);
 %!   fprintf (fid, "function z = b(x)\n z = x+1; end\n");
@@ -856,6 +858,7 @@
 %!   assert (d{2} (3), 6);
 %! unwind_protect_cleanup
 %!   unlink (f);
+%!   path (save_path);
 %! end_unwind_protect
 */