-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] autoload .oct file functions #180
[wip] autoload .oct file functions #180
Conversation
For all compiled function names, check Octave's autoload list for any entries matching the .oct file name. If any matches are found, recursively test those function names. Fixes gnu-octave#178.
Thanks Colin & Mike for working on this. |
@mtmiller I'm sorry, I didn't see this before trying it myself! |
if (strcmp(type, 'octfile')) | ||
len = numel (what) + 4; | ||
list = autoload (); | ||
pmatch = @(e) (numel (e.file) > len) && strcmp (e.file(end-len+1:end), [what '.oct']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this only matches the name of the oct file: what if an oct file has same name in a different path? In my patch, I used pwd/what
but I'm not sure that's right either---should doctest meh.oct
work if meh.oct is in the path but not in pwd? Maybe your way is less risky...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this only matches the basename of the .oct file.
I didn't want to use pwd
because the user could be testing any .oct file in the load path, right?
It's true that this is a weaker check, a stronger check might be to get the full path to the .oct file with which
or file_in_loadpath
?
@@ -26,7 +26,7 @@ | |||
type = 'texinfo'; | |||
elseif (exist (what) == 3) % .oct/.mex | |||
[~, what, ~] = fileparts (what); % strip extension if present | |||
type = 'function'; % then access like any function | |||
type = 'octfile'; % then access like any function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my patch, I made a distinction b/w doctest foo
and doctest foo.oct
: whereby the former tests only the function called foo and the latter tests all functions in foo.oct
(including foo
itself). Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I like your approach better.
len = numel (what) + 4; | ||
list = autoload (); | ||
pmatch = @(e) (numel (e.file) > len) && strcmp (e.file(end-len+1:end), [what '.oct']); | ||
idx = find (arrayfun (pmatch, list)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this arrayfun approach probably nicer than my approach! Nice shortcut with numel.
Note for the record: there is no return after the recursion, this is because |
Seems like we converged on almost the same approach, I'll review your branch and maybe you can incorporate some of my differences into yours. |
I'll close this as we're converging our commits at #179. |
@cbm755 something like this, works for me with all of my test cases.
Side effect being, if you
doctest specific_function
, and that function is also the name of a .oct file, it will also test all the other functions in the .oct file.