Skip to content

Commit

Permalink
.gitattributes: ignore test files, don't ignore test framework
Browse files Browse the repository at this point in the history
As of PHPCS 4.0, the tests will no longer ship in a packaged version of the repo 🎉

However, while this removes a lot of friction, it can also cause some, as quite a few external standards use the PHPCS native test framework to run their tests. To continue to do so, those external standards would now have to use `--prefer-source`, which would make their builds a lot slower and will cause extra support questions from new contributors to those standards.

This commit proposes a solution to this issue by making a few small changes to the `.gitattributes` file.
With these updates directives in place, the PHPCS native test _framework_ will still be included in the packaged up versions, but the test _files_ will not be.

In practice, this means that the following files should still be included in a packaged up version:
* `/tests/AllTests.php`
* `/tests/bootstrap.php`
* `/tests/FileList.php`
* `/tests/TestSuite.php`
* `/tests/Core/AbstractMethodUnitTest.php`
* `/tests/Core/AllTests.php`
* `/tests/Standards/AbstractSniffTest.php`
* `/tests/Standards/AllSniffs.php`

... but that all other test files will be excluded.

This removes the need for external standards to use `--prefer-source`.
  • Loading branch information
jrfnl committed Dec 6, 2023
1 parent 8b5e6e9 commit 1da2742
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production/
# https://blog.madewithlove.be/post/gitattributes/
#
.github/ export-ignore
scripts/ export-ignore
src/Standards/**/Tests/ export-ignore
tests/ export-ignore
.cspell.json export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.yamllint.yml export-ignore
phpcs.xml.dist export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
.github/ export-ignore
scripts/ export-ignore
src/Standards/**/Tests/ export-ignore
tests/Core/**/ export-ignore
.cspell.json export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.yamllint.yml export-ignore
phpcs.xml.dist export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
tests/Core/ErrorSuppressionTest.php export-ignore
tests/Core/IsCamelCapsTest.php export-ignore

#
# Declare files that should always have CRLF line endings on checkout.
Expand Down

0 comments on commit 1da2742

Please sign in to comment.