# HG changeset patch # User Rik # Date 1386096320 28800 # Node ID b675665ce328b8ecb292d4f8516f5a6049a7ab5c # Parent 70e83c641b48177c7e83b03a6515cc687c676e28 Simplify directory testing code for rundemos, runtests. * rundemos.m, runtests.m: Use canonicalize_file_name to both check for existence of file and return and absolute path. diff -r 70e83c641b48 -r b675665ce328 scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m Tue Dec 03 09:35:54 2013 -0800 +++ b/scripts/testfun/rundemos.m Tue Dec 03 10:45:20 2013 -0800 @@ -36,13 +36,11 @@ dirs = ostrsplit (path (), pathsep ()); do_class_dirs = true; elseif (nargin == 1) - if (is_absolute_filename (directory)) - dirs = {directory}; - elseif (isdir (directory)) - dirs = {canonicalize_file_name(directory)}; - else - if (directory(end) == filesep ()) - directory = directory(1:end-1); + dirs = {canonicalize_file_name(directory)}; + if (isempty (dirs{1})) + ## Search for directory name in path + if (directory(end) == '/' || directory(end) == '\') + directory(end) = []; endif fullname = find_dir_in_path (directory); if (isempty (fullname)) diff -r 70e83c641b48 -r b675665ce328 scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m Tue Dec 03 09:35:54 2013 -0800 +++ b/scripts/testfun/runtests.m Tue Dec 03 10:45:20 2013 -0800 @@ -36,13 +36,11 @@ dirs = ostrsplit (path (), pathsep ()); do_class_dirs = true; elseif (nargin == 1) - if (is_absolute_filename (directory)) - dirs = {directory}; - elseif (isdir (directory)) - dirs = {canonicalize_file_name(directory)}; - else - if (directory(end) == filesep ()) - directory = directory(1:end-1); + dirs = {canonicalize_file_name(directory)}; + if (isempty (dirs{1})) + ## Search for directory name in path + if (directory(end) == '/' || directory(end) == '\') + directory(end) = []; endif fullname = find_dir_in_path (directory); if (isempty (fullname))