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

Updated and simplified PHP testing structure #8558

Merged
merged 11 commits into from May 4, 2021

Conversation

haberman
Copy link
Member

@haberman haberman commented May 4, 2021

This PR simplifies a number of issues around the PHP testing setup:

  • Before the pure-PHP and C extension testers used different autoloaders. This PR consolidates them into a single autoloader, created by composer.
  • We also remove the custom PHPUnit version selection logic in test.sh in favor of letting Composer pick the correct dependencies for each PHP version.
  • Before the pure-PHP and C extension used different PHPUnit invocation strategies: pure-PHP used a phpunit.xml file, while the C extension enumerated the list of testing files in a shell script. Now both use the same strategy: we run PHPUnit on a directory, which automatically tests all of the files matching *Test.php in that directory.
  • Consolidated on a single autoloader, created by composer.
  • We now rely on autoloading to import all test protos. require_once() calls for test protos are removed.
  • For now the valgrind tests are removed. A follow-up PR will re-enable them in a more robust way.
  • Optimized both test proto generation and the custom extension build to avoid unnecessary work when the files are already up to date.
  • Added assertions to verify that the C test doesn't use PHP sources, this should eliminate the need for separate "C" and "mixed" tests.
  • Removed obsolete rules from tests.sh.

- Consolidated on a single autoloader, created by composer.
- Consolidated on a single phpunit invocation strategy: we run
  phpunit on a directory, which will run all tests matching *Test.php
  in that directory.
- We now rely on autoloading to import all test protos. require_once()
  calls for test protos are removed.
- For now the valgrind tests are removed. A follow-up PR will re-enable
  them in a more robust way.
1. Replace custom PHPUnit-selection logic in test.sh with generic
   composer version selection.
2. Optimized both test proto generation and the custom extension
   build to avoid unnecessary work when the files are already up
   to date.
Also removed undefined_test.php and fixed Makefile.am.

spl_autoload_register(function($class) {
if (strpos($class, "Google\\Protobuf") === 0) {
throw new Exception("When using the C extension, we should not load runtime class: " . $class);
Copy link
Contributor

Choose a reason for hiding this comment

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

well known types are bundled in c extension?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, they are as of #7944

@haberman haberman merged commit 8b87075 into protocolbuffers:master May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants