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

QA/Tests: various code coverage tweaks #331

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ jobs:
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: xdebug

- name: "DEBUG: Show version details"
run: php -v

- name: 'Composer: adjust dependencies'
run: |
# Set a specific PHPCS version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public function getActualArrayKey(File $phpcsFile, $startPtr, $endPtr)
* Shouldn't be possible. Either way, if it's not one of the above types,
* this is not a key we can handle.
*/
return;
return; // @codeCoverageIgnore
}
}
}
3 changes: 2 additions & 1 deletion PHPCSUtils/Utils/FunctionDeclarations.php
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@ public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr)

$returnValue['parenthesis_opener'] = $nextNonEmpty;
if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
return false;
// Shouldn't be possible, but just in case.
return false; // @codeCoverageIgnore
}

$returnValue['parenthesis_closer'] = $tokens[$nextNonEmpty]['parenthesis_closer'];
Expand Down
3 changes: 2 additions & 1 deletion PHPCSUtils/Utils/Namespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ public static function findNamespacePtr(File $phpcsFile, $stackPtr)
if (isset($tokens[$prev]['scope_condition']) === true) {
$prev = $tokens[$prev]['scope_condition'];
} elseif (isset($tokens[$prev]['scope_opener']) === true) {
$prev = $tokens[$prev]['scope_opener'];
// Shouldn't be possible, but just in case.
$prev = $tokens[$prev]['scope_opener']; // @codeCoverageIgnore
}

continue;
Expand Down
17 changes: 17 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,25 @@
>

<testsuites>
<testsuite name="RunFirst">
<!--
A number of tests need process isolation to allow for recording code coverage on
the setting of function local static variables.
However, using process isolation runs into trouble with PHPUnit 4.x/PHPCS 2.6.0.
Executing these specific tests in a separate testsuite, which is run
before the full test suite, will allow for the code coverage for these methods
to be recorded properly, while still allowing the tests to run on all supported
PHP/PHPUnit/PHPCS combinations.
-->
<file>./Tests/BackCompat/BCTokens/EmptyTokensTest.php</file>
<file>./Tests/Utils/Namespaces/NamespaceTypeTest.php</file>
<file>./Tests/Utils/Numbers/GetCompleteNumberTest.php</file>
</testsuite>
<testsuite name="PHPCSUtils">
<directory suffix="Test.php">./Tests/</directory>
<exclude>Tests/BackCompat/BCTokens/EmptyTokensTest.php</exclude>
<exclude>Tests/Utils/Namespaces/NamespaceTypeTest.php</exclude>
<exclude>Tests/Utils/Numbers/GetCompleteNumberTest.php</exclude>
</testsuite>
</testsuites>

Expand Down