-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix --filter format used by PHPStorm #6364
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
base: 12.4
Are you sure you want to change the base?
Conversation
It was broken by PR sebastianbergmann#6272. As far as I can tell the goal was to change the test name printed by the default printer to make it easier to copy-paste it into --filter. Example: 1) PHPUnit\TestFixture\DataProviderFilterTest::testFalse@other false test2 with data (false) Into: --filter 'testFalse@other false test2' However, the PR changed the test name more broadly than necessary. This broke --filter pattern used by PHPStorm. E.g: --filter '/PHPUnit\\TestFixture\\DataProviderFilterTest::testFalse with data set \"other false test\"$/'
CC @staabm |
@schlndh thanks for reporting. Could you describe how to reproduce the problem jn PHPStorm? |
If phpstorm is using data from a formatter and feeds it back into the filter cli option we should have a test for this e2e scenario |
@staabm I do it like this:
Here is a screen recording to make it even easier to understand: 12.3 branch: phpstorm_test_broken.mp4My branch: phpstorm_test_fixed.mp4 |
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 looks mostly good. thanks for the in-detail repro and the time you invested in making the screen recordings.
elseif (preg_match('/^(.*?)@(.+)$/', $filter, $matches)) { | ||
$filter = sprintf( | ||
'%s.*with data set "@%s"$', | ||
'%s.*with data set "%s"$', |
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.
just to re-iterate: this reverts my change which caused the bug/BC break.
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.
The real bug/BC break was in dataSetAsString
. This just has to match it, so that the short test@data
filter syntax works. The PHPStorm's filter doesn't execute this code at all, because it's a full regex pattern (i.e. starting with /
).
@@ -0,0 +1,22 @@ | |||
--TEST-- |
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.
we need another test with a numbered dataprovider. this one here covers only named dataproviders.
and I think we should land the new tests on PHPUnit 11+ to make sure all PHPUnit versions are on the same page
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.
Maybe even for PHPUnit >= 10.
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 opened a separate PR that adds E2E tests both for named and numbered data providers. If you want, I can also add a simpler version of the test like this to it. Otherwise, I'd just delete the test from this PR.
@@ -0,0 +1,22 @@ | |||
--TEST-- | |||
phpunit --filter '/PHPUnit\\TestFixture\\DataProviderFilterTest::testFalse with data set \"other false test\"$/' ../../_files/DataProviderFilterTest.php |
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.
usually we put a url to the underlying issue/pr in --TEST--
.
in this case it would be
--TEST--
https://github.com/sebastianbergmann/phpunit/pull/6364
And as mentioned above, I think we should have a separate e2e test which feeds the output of the teamcity formatter back into the --filter option, so we mimick the phpstorm use-case as close as possible |
Do you have any suggestion about the best way to do it? I tried first running the whole test class with I suppose that a weaker alternative might be hard-coding the |
I think you could either
maybe @sebastianbergmann has a better idea |
@sebastianbergmann Since the PhpStorm team hasn't responded to your question on the E2E test PR, can we proceed with this PR regardless? IMO the fix makes sense in general, not just due to PhpStorm. I'd just add a simple test for the numbered dataprovider here for completeness. |
It was broken by PR #6272. As far as I can tell the goal was to change the test name printed by the default printer to make it easier to copy-paste it into --filter.
Example from PHPUnit's own tests:
Can be copy-pasted into
--filter
like this:However, IMO the PR changed the test name more broadly than necessary. This broke the --filter pattern used by PHPStorm (i.e.
No tests executed!
). E.g:It would have have an extra
@
like this:But the
@
is not present in the teamcity output that PHPStorm uses (they seem to use thelocationHint
). So PHPStorm (and similar tools) would have to hack the test name to add it (which would presumably make the whole thing even more tied to PHPUnit's internal behavior).IMO the
--filter
used by PHPStorm is pretty reasonable, so I'm attempting to restore support for it, while maintaining the new name used by the default printer for easy copy-pasting.