Skip to content

[PHPUnitBridge] When only ignoreFile is passed in SYMFONY_DEPRECATIONS_HELPER, deprecations no longer fail tests #45919

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

Closed
mondrake opened this issue Apr 2, 2022 · 4 comments · Fixed by #45923

Comments

@mondrake
Copy link
Contributor

mondrake commented Apr 2, 2022

Symfony version(s) affected

6.1.0

Description

When only ignoreFile is passed in SYMFONY_DEPRECATIONS_HELPER, deprecations no longer fail tests, unless you also specifically set max[total]=0

How to reproduce

Use an env var like (from phpunit.xml)

<env name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=/var/www/d10/core/deprecation-ignore.txt"/>

Run tests that have unignored deprecations reported;

The exit code of PHPUnit is 0, not 1 as you would expect.

Add max[total]=0

<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=0&ignoreFile=/var/www/d10/core/deprecation-ignore.txt"/>

Rerun tests;

The exit code of PHPUnit is 1.

Possible Solution

No response

Additional Context

No response

@nicolas-grekas
Copy link
Member

Doesn't #45921 also fix this?

@mondrake
Copy link
Contributor Author

mondrake commented Apr 3, 2022

Actually, this could well be working as designed.

When you do not set any SYMFONY_DEPRECATIONS_HELPER variable, the bridge ends up configured by

if (!$mode) {
return $this->configuration = Configuration::fromNumber(0);
}

which is essentially as if configuring with SYMFONY_DEPRECATIONS_HELPER='strict' that sets max[total]=0

But when you pass a SYMFONY_DEPRECATIONS_HELPER='ignoreFile=xxx', the configuration is by

return $this->configuration = Configuration::fromUrlEncodedString((string) $mode);

which in turn sets the thresholds to 999999 in

foreach ($groups as $group) {
if (!isset($this->thresholds[$group])) {
$this->thresholds[$group] = 999999;
}
}

So, either we change the default threshold from 999999 to 0 to make 'strict' reporting the default when SYMFONY_DEPRECATIONS_HELPER is set but does not specifically set thresholds (but that will impact live testing, potentially), or we document that if you move from no use of SYMFONY_DEPRECATIONS_HELPER to using it to indicate the ignoreFile, then you also need to specifically set the max['whatever']=xx thresholds.

@nicolas-grekas
Copy link
Member

Good catch. That's a bug to me. Not setting any max should be the same as not setting SYMFONY_DEPRECATIONS_HELPER at all.

@mondrake
Copy link
Contributor Author

mondrake commented Apr 3, 2022

OK then, let's change the default.

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

Successfully merging a pull request may close this issue.

3 participants