Skip to content
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

Trailing slash in XdebugFilterScriptGenerator.php breaks coverage in windows #3834

Closed
shivammathur opened this issue Sep 7, 2019 · 2 comments
Closed

Comments

@shivammathur
Copy link
Contributor

@shivammathur shivammathur commented Sep 7, 2019

Q A
PHPUnit version 8.3
PHP version 7.2.10
Installation Method Composer

Trailing slash after %s in XdebugFilterScriptGenerator results in 0% coverage on windows as it has backslash as separator.

$files[] = \sprintf('%s/', $path);

Current code on windows generates this xdebug-filter.php

<?php declare(strict_types=1);
if (!\function_exists('xdebug_set_filter')) {
    return;
}

\xdebug_set_filter(
    \XDEBUG_FILTER_CODE_COVERAGE,
    \XDEBUG_PATH_WHITELIST,
    [
        'C:\path\to\dir/'
    ]
);

Correct xdebug-filter.php should be

<?php declare(strict_types=1);
if (!\function_exists('xdebug_set_filter')) {
    return;
}

\xdebug_set_filter(
    \XDEBUG_FILTER_CODE_COVERAGE,
    \XDEBUG_PATH_WHITELIST,
    [
        'C:\path\to\dir\\'
    ]
);

So constant DIRECTORY_SEPARATOR can be used with proper escaping.

@shivammathur
Copy link
Contributor Author

@shivammathur shivammathur commented Sep 7, 2019

Hi @sebastianbergmann I will submit a PR in a bit.

Loading

@shivammathur
Copy link
Contributor Author

@shivammathur shivammathur commented Sep 7, 2019

@sebastianbergmann Your patch gives a syntax error. See #3835 (comment)

Loading

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

Successfully merging a pull request may close this issue.

None yet
2 participants