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
Assignees
Labels
event/code-sprint/2019-09 PHPUnit Code Sprint: September 2019 type/bug Something is broken

Comments

@shivammathur
Copy link
Contributor

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.

@sebastianbergmann sebastianbergmann self-assigned this Sep 7, 2019
@sebastianbergmann sebastianbergmann added type/bug Something is broken event/code-sprint/2019-09 PHPUnit Code Sprint: September 2019 labels Sep 7, 2019
@shivammathur
Copy link
Contributor Author

shivammathur commented Sep 7, 2019

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

@shivammathur
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event/code-sprint/2019-09 PHPUnit Code Sprint: September 2019 type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants