Skip to content

Conversation

@carlos-granados
Copy link
Contributor

If you have been debugging your code with Xdebug and forget to turn it off, when running Behat it can be 2-3 times slower, even if you don't set any breakpoints or actually use Xdebug. Following what other tools like PHPStan or Rector do, with this PR by default we disable Xdebug when running Behat. We add a new --xdebug command line option that allows you to run Behat without disabling Xdebug.

This uses the https://github.com/composer/xdebug-handler library, also used by PHPStan and Rector to provide this same functionality

Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is super helpful, thanks ❤️

@acoulton acoulton merged commit 05ac243 into Behat:master Dec 9, 2024
17 checks passed
@carlos-granados carlos-granados deleted the disable-xdebug branch December 9, 2024 10:00
@ostrolucky
Copy link

This broke phpstorm's behat debug run. You should consider reverting it.

@carlos-granados
Copy link
Contributor Author

@ostrolucky can you provide more details?

@ostrolucky
Copy link

ostrolucky commented Dec 23, 2024

Phpstorm doesn't know to pass --xdebug flag so debugging behat tests where phpstorm invokes tests like on screenshot below does not trigger breakpoints anymore
image

@carlos-granados
Copy link
Contributor Author

@ostrolucky You should be able to edit the Behat run configuration to add the --xdebug flag in the test runner options. I just tested this in my PHPStorm installation and it works correctly, please see this screenshot:
Screenshot 2024-12-23 at 14 16 33

@ostrolucky
Copy link

ostrolucky commented Dec 23, 2024

Yeah that seems better than having to define BEHAT_ALLOW_XDEBUG=1 env variable. However, this stuff needs to be done each time you are debugging, or define it as default for behat configuration (which is going to defeat the purpose of making this optional). In any case it's quite non-transparent and different from other test runners like phpunit. I think behat should do it the same way as phpunit. Otherwise we need to reach out to jetbrains to update their IDE, so that this works out of the box like it should.

@carlos-granados
Copy link
Contributor Author

Thanks @ostrolucky if you feel that there is a better way to handle this, feel free to open an issue in this repository with your suggestion and we will consider it. Or, even better, submit a PR 😄

@cooperaj
Copy link

cooperaj commented Jan 9, 2025

Spent most of yesterday fighting my environment, getting highly annoyed that debugging had broken for us. I was at point of scouring the Jetbrains issue tracker and manually debugging their behat helper scripts.

Then I found that our renovate run had brought in a point release of behat that has this (workflow breaking) change in it.

Our PHPStorm test configs only ever enabled debugging if you requested it so we didn't see any unnecessary slowdown. We've now implemented the test runner flag in the configs and are back to normal.

It's a good feature, I just wish it hadn't appeared as it did and been made the default operation.

@acoulton
Copy link
Contributor

acoulton commented Jan 9, 2025

@cooperaj apologies for the hassle - it's clear that we hadn't properly understood the impact this change would have. This is fixed by #1581 which will be in the 3.18.0 release, coming this evening or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants