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

3.0: Tests: add a bootstrap file #1907

Merged
merged 1 commit into from
Jul 9, 2020
Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 30, 2020

While not strictly necessary, it makes life easier to have this bootstrap in place.

The bootstrap file will:

  • Load the PHPCS autoloader (was previously done from the command-line);
  • Load the Composer autoload file.
  • Will automatically set the PHPCS_IGNORE_TESTS environment variable to the correct value to prevent running tests from other standards.

For locally running the tests after having run composer install, all should work fine.

For locally running the tests with a git clone of PHPCS, a phpunit.xml overload file can be used with a env variable PHPCS_DIR to point the bootstrap to that install. Do make sure that PHPCSUtils is installed and registered in the installed_paths of that install if you do so.

While not strictly necessary, it makes life easier to have this bootstrap in place.

The bootstrap file will:
* Load the PHPCS autoloader (was previously done from the command-line);
* Load the Composer autoload file.
* Will automatically set the `PHPCS_IGNORE_TESTS` environment variable to the correct value to prevent running tests from other standards.
Copy link
Member

@dingo-d dingo-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For locally running the tests with a git clone of PHPCS, a phpunit.xml overload file can be used with a env variable PHPCS_DIR to point the bootstrap to that install. Do make sure that PHPCSUtils is installed and registered in the installed_paths of that install if you do so.

Should we put this in a readme or wiki, just not to forget about it and to point people to, if it pops up in the issues?

@jrfnl
Copy link
Member Author

jrfnl commented Jul 1, 2020

@dingo-d I fully agree, though I think it should go in the CONTRIBUTING.md doc as running unit tests is typically something for contributors.

I already have this written up, or rather, I have a local commit with:

  • Updated Readme
  • Updated Contributing
  • Update bug report template
  • End-user upgrade guide -> to be added the changelog
  • Dev upgrade guide (i.e. for standards extending WPCS) -> to be added to the wiki

As the develop branch is the default branch in this repo, if I would pull those docs now, those would start showing straight away, while all of that will not apply yet until 3.0 has a (RC) release, so it would be really confusing for people who try to install the latest (2.x) release.

So as per my note in #1905:

Note: the install/upgrade instructions in the Readme and other documentation will be addressed in a separate PR late in the 3.0 cycle, so as not to confuse people using the latest release, while 3.0.0 development is ongoing.

@jrfnl jrfnl requested a review from GaryJones July 8, 2020 16:50
Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed review - there was a bit more going on in this PR, and I wanted to have the time to get my head around what was actually happening.

@GaryJones GaryJones merged commit 3948114 into develop Jul 9, 2020
@GaryJones GaryJones deleted the 3.0/add-test-bootstrap branch July 9, 2020 19:04
@GaryJones
Copy link
Member

I wonder if PHPCSExtra / PHPCSUtils could handle a generic version of this logic in a function - find PHPCS directory, autoload PHPCS files, ignore all but a standard passed in as a string - so that WPCS and other standards packages could simply call \PHPCSExtra\bootstrap_tests('My-Cool-Standard'); or whatever.

@jrfnl
Copy link
Member Author

jrfnl commented Jul 9, 2020

Sorry for the delayed review - there was a bit more going on in this PR, and I wanted to have the time to get my head around what was actually happening.

@GaryJones No worries, I just wanted to make sure (with the review request) it had not been overlooked/escaped attention.

I wonder if PHPCSExtra / PHPCSUtils could handle a generic version of this logic in a function - find PHPCS directory, autoload PHPCS files, ignore all but a standard passed in as a string - so that WPCS and other standards packages could simply call \PHPCSExtra\bootstrap_tests('My-Cool-Standard'); or whatever.

I like the idea - would be something for PHPCSUtils. I will need to have a think about it. Might be good to open an issue about it in that repo.

There is a related issue open already to create a PHP/PHPCS/PHPUnit cross-version compatible alternative to the PHPCS native base test class AbstractSniffUnitTest, which would take priority and would partially solve this already anyhow.
See: PHPCSStandards/PHPCSUtils#72

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.

3 participants