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

Fix test:php commands #7589

Merged
merged 8 commits into from
Jul 18, 2023
Merged

Fix test:php commands #7589

merged 8 commits into from
Jul 18, 2023

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Jul 17, 2023

This fixes an issue I experienced when running npm run test:php:

> amp-wp@ test:php .../amp
> wp-env run tests-wordpress 'env WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args'

ℹ Starting 'env WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args' on the tests-wordpress container. 

OCI runtime exec failed: exec failed: unable to start container process: exec: "env WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args": stat env WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args: no such file or directory: unknown
✖ Command failed with exit code 126

It also simplifies the test:php:* commands and removes test:php:help which is not needed.

It also fixes PHPUnit issues specifically encountered when running in wp-env. Fixes #7590.

@westonruter westonruter added this to the v2.4.2 milestone Jul 17, 2023
@westonruter westonruter marked this pull request as ready for review July 17, 2023 20:49
@westonruter westonruter requested a review from thelovekesh July 17, 2023 20:49
@westonruter westonruter changed the title Fix test:php command Fix test:php commands Jul 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 17, 2023

Plugin builds for 5ada676 are ready 🛎️!

@@ -262,7 +262,9 @@ public function test_converter( $source, $expected = null, $args = [], $expected
}

// Normalize across different testing environments where WP_TESTS_DOMAIN varies.
$current_origin = '//' . WP_TESTS_DOMAIN;
$tests_domain = WP_TESTS_DOMAIN;
$tests_domain = strtok( $tests_domain, ':' ); // In wp-env, the WP_TESTS_DOMAIN constant can erroneously include the port: 'localhost:8889'.
Copy link
Member Author

@westonruter westonruter Jul 17, 2023

Choose a reason for hiding this comment

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

Relatedly, I previously reported WordPress/gutenberg#41038 and fixed via WordPress/gutenberg#41039 an issue where the URL scheme was included in the WP_TESTS_DOMAIN (e.g. http://localhost). Apparently the port number is now erroneously being added.

Copy link
Collaborator

Choose a reason for hiding this comment

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

AMP_Form_Sanitizer_Test tests were passing for some time in wp-env. Seems like this has been resurfaced again.

Copy link
Collaborator

@thelovekesh thelovekesh left a comment

Choose a reason for hiding this comment

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

LGTM!

@westonruter westonruter merged commit 6f10bb5 into develop Jul 18, 2023
@westonruter westonruter deleted the fix/test-php-dev-env branch July 18, 2023 14:05
@westonruter westonruter modified the milestone: v2.4.2 Jul 18, 2023
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHPUnit tests fail in development environment
2 participants