You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In TestSuite.fromName, isdir() is used to determine if the string argument "name" is a subdirectory (TestSuite.m:199). If isdir(name) returns true, xUnit calls cd(name) in TestSuiteInDir.gatherTestCases() (TestSuiteInDir.m:45). The problem is that Matlab knows three types of paths (absolute/full paths, relative paths, partial paths [1]) and isdir() accepts all three of them although this is not explicitly said in the documentation. This may cause an exception when cd() is called in gatherTestCases() because cd() handles only absolute and relative paths (the documentation is clear here). This causes XUnit to throw an exception whenever the name argument to TestSuite.fromName() happens to be a partial path.
Demo:
Create an empty directory
Change into the empty directory
Start Matlab in this directory
Execute isdir('elmat')
Execute cd('elmat')
isdir('elmat') will return logical one because MATLABROOT/toolbox/matlab/elmat is in the search path hence "elmat" is a partial path. cd('elmat') will throw an exception because "elmat" is neither a relative nor an absolute path.
Moreover isdir() is called before ispackage() in TestSuite.fromName() so if a package name happens to be a partial path, then an exception will be thrown as well.
I have run into this problem numerous times as well. I've generally fixed this in my test utilities higher up the chain, but reading through your issue I believe I've figured out a way to actually resolve the issue which I've submitted as #16.
In TestSuite.fromName, isdir() is used to determine if the string argument "name" is a subdirectory (TestSuite.m:199). If isdir(name) returns true, xUnit calls cd(name) in TestSuiteInDir.gatherTestCases() (TestSuiteInDir.m:45). The problem is that Matlab knows three types of paths (absolute/full paths, relative paths, partial paths [1]) and isdir() accepts all three of them although this is not explicitly said in the documentation. This may cause an exception when cd() is called in gatherTestCases() because cd() handles only absolute and relative paths (the documentation is clear here). This causes XUnit to throw an exception whenever the name argument to TestSuite.fromName() happens to be a partial path.
Demo:
isdir('elmat') will return logical one because MATLABROOT/toolbox/matlab/elmat is in the search path hence "elmat" is a partial path. cd('elmat') will throw an exception because "elmat" is neither a relative nor an absolute path.
Moreover isdir() is called before ispackage() in TestSuite.fromName() so if a package name happens to be a partial path, then an exception will be thrown as well.
[1] http://www.mathworks.com/help/matlab/matlab_env/specify-file-names.html
The text was updated successfully, but these errors were encountered: