Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 11, 2023

Description

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.

Suggested changelog entry

Update the existing changelog entry:

-- Composer installs no longer include any test files
+- Composer installs no longer include test files, with the exception of the test framework files

Related issues/external references

Fixes squizlabs/PHP_CodeSniffer#3158

@jrfnl jrfnl added this to the 4.0.0 milestone Nov 11, 2023
@jrfnl jrfnl force-pushed the phpcs-4.x/gitattributes-dont-ignore-test-framework-files branch from ae48201 to 7541d94 Compare November 11, 2023 04:11
@jrfnl jrfnl changed the title .gitattributes: ignore test files, don't ignore test framework 4.0 | .gitattributes: ignore test files, don't ignore test framework Dec 2, 2023
@jrfnl jrfnl force-pushed the phpcs-4.x/gitattributes-dont-ignore-test-framework-files branch from 7541d94 to 1da2742 Compare December 6, 2023 00:38
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`.
jrfnl added a commit that referenced this pull request Apr 14, 2025
.. but the test _framework_ files will be.

This is set up in this way to prevent external standards having to use `--prefer-source` when their (sniff) tests are using the PHPCS test framework.

Fixes squizlabs/PHP_CodeSniffer 1908
Fixes squizlabs/PHP_CodeSniffer 3158
Closes #73
Fixes 636

Co-authored-by: jrfnl <[email protected]>
@jrfnl
Copy link
Member Author

jrfnl commented Apr 15, 2025

Closing as fixed via #993

@jrfnl jrfnl closed this Apr 15, 2025
@jrfnl jrfnl deleted the phpcs-4.x/gitattributes-dont-ignore-test-framework-files branch April 15, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants