Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Partial paths are mishandled #14

Closed
chrTUB opened this issue Aug 21, 2015 · 1 comment
Closed

Partial paths are mishandled #14

chrTUB opened this issue Aug 21, 2015 · 1 comment

Comments

@chrTUB
Copy link

chrTUB commented Aug 21, 2015

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.

[1] http://www.mathworks.com/help/matlab/matlab_env/specify-file-names.html

@bauglir
Copy link
Contributor

bauglir commented Jan 14, 2016

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants