Handle minimum path in .xdebug directory discovery#1062
Handle minimum path in .xdebug directory discovery#1062mho22 wants to merge 3 commits intoxdebug:masterfrom
.xdebug directory discovery#1062Conversation
|
Hi, sorry for the slow reply. I saw you just created an issue for it too. I think this makes sense — would it be possible to create a test case for this perhaps? cheers, |
|
No need to apologize at all, I'm sorry I didn't create an issue first. I'll try to write a test case, but I'm not used to doing so in a project like Xdebug, so we may need a few back-and-forths. I'll get back to you once it's done. |
|
Your best bet might be looking at https://github.com/xdebug/xdebug/tree/master/tests/debugger/maps/skip-vendor-directory as an example. I suspect creating the right directory structure is the main problem (and I don't have a clever answer either at the moment). |
|
@derickr Thank you for the advice! I ended up adding the test as |
| --FILE-- | ||
| <?php | ||
| require __DIR__ . '/../../dbgp/dbgpclient.php'; | ||
| $filename = dirname(__FILE__) . '/foo/bar/file.inc'; |
There was a problem hiding this comment.
I don't think this test tests the thing you're fixing, as the dirname(__FILE__) is something that's already going to be several levels deep — where you want to test something that's only two or three path levels.
I think you might be able to get away with using sys_get_temp_dir() (like below in line 13 for the log file), create a directory in there (include getenv('UNIQ_RUN_ID') . getenv('TEST_PHP_WORKER') in the directory name to allow for parallelism), copy your test file file.inc and .xdebug directory there, and then set the breakpoints etc.
And then also remove them at the end of the test, with the --CLEAN-- section: https://php.github.io/php-src/miscellaneous/writing-tests.html#clean
There was a problem hiding this comment.
Of course... I'm not sure whether sys_get_temp_dir() guarantees that the .xdebug directory will be located at the root of the test, but if it does, then I think my latest commit should fix the issue.
There was a problem hiding this comment.
@derickr I'm not sure whether I should hit "re-request review," tag you here, or simply do nothing. I don't mean to rush you, I just want to make sure I haven't forgotten to do something on my end.
There was a problem hiding this comment.
I'll get to it, but I'm about to do two conferences and have a lot of things on my plate. I'm not forgetting about it, but I do want to test it with the right (ie, none) parent paths locally too.
There was a problem hiding this comment.
Good luck with the conferences, and feel free to ping me if you need anything.
|
I'm closing this in favour of #1070 (keeping you as commit author), which is for the right branch and has the test case "fixed" too. Thanks! |
|
@derickr Thank you! I am glad I contributed to Xdebug 🎉 |
This is some kind of unusual behavior but I stumbled upon this lately in one of my use cases. This is why I wanted to suggest this pull request. It is mainly focused on the
.xdebugdirectory discovery for path mappings/skippings. Long story short : It couldn't find my.xdebugdirectory located at the root of my environment.Here is a more precise use case :
Based on these lines in
src/lib/maps/maps.c> line183:If my current debugged file is
/foo/bar/baz/qux/file.php, then :Nice. Now :
If my current debugging directory is
/foo/bar/file.php, then :While
grand_dirshould probably return "/" instead (or almost "").My suggestion would be to simply replace
>with>=.Currently it gives this :
While with my suggestion :
What do you think?