Skip to content

Commit ae48201

Browse files
committed
.gitattributes: ignore test files, don't ignore test framework
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`.
1 parent bcede6f commit ae48201

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

.gitattributes

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production/
66
# https://blog.madewithlove.be/post/gitattributes/
77
#
8-
.github/ export-ignore
9-
scripts/ export-ignore
10-
src/Standards/**/Tests/ export-ignore
11-
tests/ export-ignore
12-
.cspell.json export-ignore
13-
.gitattributes export-ignore
14-
.gitignore export-ignore
15-
phpcs.xml.dist export-ignore
16-
phpstan.neon.dist export-ignore
17-
phpunit.xml.dist export-ignore
8+
.github/ export-ignore
9+
scripts/ export-ignore
10+
src/Standards/**/Tests/ export-ignore
11+
tests/Core/**/ export-ignore
12+
.cspell.json export-ignore
13+
.gitattributes export-ignore
14+
.gitignore export-ignore
15+
phpcs.xml.dist export-ignore
16+
phpstan.neon.dist export-ignore
17+
phpunit.xml.dist export-ignore
18+
tests/Core/ErrorSuppressionTest.php export-ignore
19+
tests/Core/IsCamelCapsTest.php export-ignore
1820

1921
#
2022
# Declare files that should always have CRLF line endings on checkout.

0 commit comments

Comments
 (0)