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

Files that have only \r (CR, 0x0d) EOL characters are not handled correctly #885

Closed
kolesar-andras opened this issue Nov 23, 2021 · 4 comments
Assignees

Comments

@kolesar-andras
Copy link

Q A
php-code-coverage version 9.2.9
PHP version 7.4.3
Driver Xdebug
Xdebug version (if used) 2.9.2
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 9.5.10

Files that have only \r (CR, 0x0d) characters on line ends and having at least two comment lines cause failure:

Generating code coverage report in HTML format ... $nonCommentLinesOfCode must not be negative

Linux command wc -l shows 0 for these files beacuse it counts LF characters. Number of lines is 1 because no LF characters are in the file. $nonCommentLinesOfCode = 1-2 = -1 triggers the bug.

Macintosh files before OS X had this type of line endings.

Similar to previously fixed issue #831.

@kolesar-andras
Copy link
Author

Example file: source_without_lf_only_cr.php.txt

@sebastianbergmann
Copy link
Owner

Do you still see this problem in php-code-coverage 9.2.11?

@kolesar-andras
Copy link
Author

Yes, unfortunately.

  - Upgrading phpunit/php-code-coverage (9.2.9 => 9.2.11): Extracting archive
  - Upgrading phpunit/phpunit (9.5.10 => 9.5.14): Extracting archive
[...]
$ phpunit
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

No tests executed!

Generating code coverage report in HTML format ... $nonCommentLinesOfCode must not be negative

@sebastianbergmann
Copy link
Owner

It appears that you have different installations of PHPUnit mixed up.

For instance, you may have used Composer to install PHPUnit and have configured the autoloader generated by Composer as PHPUnit's bootstrap script but then you invoke PHPUnit using an executable other than vendor/bin/phpunit, for example.

$ phpunit implies that you are invoking PHPUnit from your $PATH, not from ./vendor/bin/phpunit where you upgraded to phpunit/php-code-coverage 9.2.11 and phpunit/phpunit 9.5.14. phpunit also prints PHPUnit 9.5.10 as version information.

@sebastianbergmann sebastianbergmann changed the title Files with CR line endings and at least two comments cause failure Files that have only \r (CR, 0x0d) EOL characters are not handled correctly Mar 3, 2022
@sebastianbergmann sebastianbergmann self-assigned this Mar 3, 2022
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

No branches or pull requests

2 participants