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

CI: Run PHPUnit tests #99

Merged
merged 29 commits into from
Apr 30, 2024
Merged

CI: Run PHPUnit tests #99

merged 29 commits into from
Apr 30, 2024

Conversation

adamziel
Copy link
Collaborator

No description provided.

@aristath
Copy link
Member

@adamziel I just merged another workflow, adding PHPCS checks.
During those checks I found some faatalities in the PHPUnit tests (a missing }) and fixed that.
Merged main in this branch too, resolving conflicts 👍

@adamziel
Copy link
Collaborator Author

Yay @aristath! It seems like something still isn't working with PHPUnit in CI, though :(

@aristath
Copy link
Member

@adamziel I fixed the issues. There is now some failing test that - as far as I understand - is a genuine error though 🤔

@adamziel
Copy link
Collaborator Author

These tests pass on my machine, though, which is super weird. Do they pass on your?

@aristath
Copy link
Member

These tests pass on my machine, though, which is super weird. Do they pass on your?

I have no idea! 😅 I'm unable to run phpunit locally right now, my environment is a bit messed-up

@brandonpayton
Copy link
Member

I made some further updates, and all unit test runs are passing on CI except PHP 7.4. Will try locally with PHP 7.4.

@brandonpayton
Copy link
Member

I'm able to reproduce the failures with PHP 7.4 locally.

@brandonpayton
Copy link
Member

This appears to be due to different tokenization where the translator sees "i" as the table name instead of "information_schema".

In PHP 8.3, logging tokens in the lexxer looks like:

token: 'FROM'                                                         
token: ''                                                                                                                                                      
token: ' '                                        
token: ''                                                       
token: ''                                                             
token: ''                                                                                                                                                      
token: ''                                                       
token: ''                                                             
token: ''                                                                                                                                                      
token: ''                                                       
token: ''                                                             
token: ''                                                                                                                                                      
token: ''                                         
token: 'information_schema' 

But in PHP 7.4, logging the same tokens looks like:

token: 'FROM'                                                                                                                                                  
token: ''                                                                                                                                                      
token: ' '                                                                                                                                                     
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                      
token: 'i'                                                                                                                                                                                                                                                                                                                    
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                                                                                                                                                                                     
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: 'n'                                                                                                                                                     
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''                                                                                                                                                      
token: ''
token: ''
token: 'f'

I'm looking into why. If this is indeed an issue, it seems remarkable that we don't have more issues with earlier versions of PHP.

@brandonpayton
Copy link
Member

brandonpayton commented Apr 30, 2024

It was a misplaced paren in the str_ends_with() polyfill: a337967

@brandonpayton
Copy link
Member

The tests are passing after choosing a fixed phpunit version and fixing a str_ends_with typo in the test bootstrap. (And after reintroducing some fixes from @aristath that I had naively reverted)

Unfortunately, I have not found a way to test from PHP 7.0 through PHP 8.3. If no phpunit version is specified, there are test errors for PHP 7.0, 8.1, 8.2, and 8.3. If a phpunit version is specified, phpunit 8.x requires at least PHP 7.2, and phpunit 7.x only allows PHP 7.x.

There is also the issue that phpunit 8.x requires a void return type on setup methods, but void is not supported in PHP 7.0.

As a compromise, the tests can run on phpunit 8.x for PHP 7.2 through PHP 8.3.

Note: With this test configuration, I was able to re-add the consider-X-as-exception test settings for now.

@brandonpayton
Copy link
Member

There are now a ton of commits where I tried various things with the CI workflow in this PR, but the actual changes remain readable.

@brandonpayton brandonpayton merged commit 23ed221 into main Apr 30, 2024
8 checks passed
@brandonpayton
Copy link
Member

Let's go ahead and merge this as the changes are test-related, and CI testing for PHP 7.2 and up is pretty good and better than no CI testing.

@adamziel
Copy link
Collaborator Author

7.2+ is good enough as WordPress phases out support for 7.0 and 7.1. Great work @brandonpayton, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants