changeset 33165:2c9b649e96c8

maint: Merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 07 Mar 2024 18:09:30 +0100
parents 4cbbc280c69d (current diff) b4f8f14dc1fb (diff)
children 7274354d68bf
files libinterp/corefcn/interpreter.cc test/Makefile.am
diffstat 6 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Thu Mar 07 08:24:51 2024 +0100
+++ b/libinterp/corefcn/interpreter.cc	Thu Mar 07 18:09:30 2024 +0100
@@ -1406,6 +1406,10 @@
 
   m_load_path.read_dir_config (".");
   m_load_path.update ();
+  // Updating the last prompt time stamp avoids skipping a fcn-info refresh
+  // so that functions in the new current directory can shadow functions
+  // further back in the load path order.
+  Vlast_prompt_time.stamp ();
 
   m_event_manager.directory_changed (sys::env::get_current_directory ());
 
--- a/test/Makefile.am	Thu Mar 07 08:24:51 2024 +0100
+++ b/test/Makefile.am	Thu Mar 07 18:09:30 2024 +0100
@@ -126,6 +126,7 @@
 include file-encoding/module.mk
 include json/module.mk
 include jupyter-notebook/module.mk
+include load-path/module.mk
 include local-functions/module.mk
 include mex/module.mk
 include nest/module.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/load-path/in-load-path/load_path_fcn.m	Thu Mar 07 18:09:30 2024 +0100
@@ -0,0 +1,3 @@
+function out = load_path_fcn ()
+out = "in-load-path";
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/load-path/module.mk	Thu Mar 07 18:09:30 2024 +0100
@@ -0,0 +1,7 @@
+load_path_TEST_FILES = \
+    %reldir%/.oct-config \
+    %reldir%/refresh-load-path.tst \
+    %reldir%/in-load-path/load_path_fcn.m \
+    %reldir%/not-in-load-path/load_path_fcn.m
+
+TEST_FILES += $(load_path_TEST_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/load-path/not-in-load-path/load_path_fcn.m	Thu Mar 07 18:09:30 2024 +0100
@@ -0,0 +1,3 @@
+function out = load_path_fcn ()
+out = "not-in-load-path";
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/load-path/refresh-load-path.tst	Thu Mar 07 18:09:30 2024 +0100
@@ -0,0 +1,38 @@
+########################################################################
+##
+## Copyright (C) 2024 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 <*65406>
+%! path_orig = path ();
+%! pwd_orig = pwd ();
+%! unwind_protect
+%!   addpath (fullfile (pwd_orig, "in-load-path"));
+%!   assert (load_path_fcn (), "in-load-path");
+%!
+%!   cd ("not-in-load-path");
+%!   assert (load_path_fcn (), "not-in-load-path");
+%! unwind_protect_cleanup
+%!   path (path_orig);
+%!   cd (pwd_orig);
+%! end_unwind_protect