# HG changeset patch # User Rik # Date 1425778146 28800 # Node ID 85c5a81c6ddd80c2ffe02047da124afd8a41edbd # Parent d9f6260cf20a02a2f39e1ed57da2408288f42182 Rewrite BIST tests for exist to pass on Windows (bug #44445). * variables.cc (Fexist): Rewrite tests for absolute and rooted files to not rely on UNIX behavior. diff -r d9f6260cf20a -r 85c5a81c6ddd libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Sat Mar 07 07:45:15 2015 -0800 +++ b/libinterp/corefcn/variables.cc Sat Mar 07 17:29:06 2015 -0800 @@ -642,6 +642,26 @@ %!assert (exist ("print_usage", "file"), 2) %!assert (exist ("print_usage", "dir"), 0) +## Don't search path for rooted relative file names +%!assert (exist ("plot.m", "file"), 2); +%!assert (exist ("./plot.m", "file"), 0); +%!assert (exist ("./%nonexistentfile%", "file"), 0); +%!assert (exist ("%nonexistentfile%", "file"), 0); + +## Don't search path for absolute file names +%!test +%! tname = tempname (pwd ()); +%! unwind_protect +%! ## open/close file to create it, equivalent of touch +%! fid = fopen (tname, "w"); +%! fclose (fid); +%! [~, fname] = fileparts (tname); +%! assert (exist (fullfile (pwd (), fname), "file"), 2); +%! unwind_protect_cleanup +%! unlink (tname); +%! end_unwind_protect +%! assert (exist (fullfile (pwd (), "%nonexistentfile%"), "file"), 0); + %!testif HAVE_CHOLMOD %! assert (exist ("chol"), 3); %! assert (exist ("chol.oct"), 3); @@ -662,16 +682,6 @@ %!error exist ("a", 1) %!error exist (1) -%!test -%! flist = dir (); -%! fname = flist(3).name; ## skip . and .. -%! assert (exist (fullfile (pwd (), fname), "file"), 2) -%! assert (exist (fullfile (pwd (), "nonexistentfile"), "file"), 0) - -%!assert (exist ("plot.m", "file"), 2); -%!assert (exist ("./plot.m", "file"), 0); -%!assert (exist ("./nonexistentfile", "file"), 0); -%!assert (exist ("nonexistentfile", "file"), 0); */ octave_value