Switch travis codecoverage from xdebug to phpdbg (#20857)

This commit changes the travis codecoverage from using xdebug to phpdbg, phpdbg seems much faster and gives similar results.

Reason for switching is we have been running into constant timeouts on our codecoverage due to the 50min job limit on travis, which means our codecoverage has not been updated in a couple of months.

* Remove xdebug as it slows tests down, switch to using phpdbg for code coverage.

* Update parameters for phpdbg

* It is qrr not qqr

* Include vendor/bin path when using phpdbg

* Use PHP 7.1 to run phpdbg

* Update phpunit dire

* Include $HOME in phpdbg call to phpunit

* Set no memory limit to avoid out of memory errors.

* Assign timeout group to test_request_url test for paypal and do not execute that on coverage as it causes a memeory timeout. Test needs optimization to run for code coverage.

* @covers usage for methods should be prefixed with ::
This commit is contained in:
Gerhard Potgieter 2018-07-20 14:34:43 +02:00 committed by Rodrigo Primo
parent b9cdc760ac
commit 8aba169654
5 changed files with 9 additions and 14 deletions

View File

@ -28,12 +28,13 @@ matrix:
dist: precise
- php: 7.2
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1 RUN_E2E=1
- php: 7.2
- php: 7.1
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
allow_failures:
- env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
before_script:
- phpenv config-rm xdebug.ini
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
- bash tests/bin/travis.sh before

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
if [[ ${RUN_CODE_COVERAGE} == 1 ]]; then
phpunit -c phpunit.xml --coverage-clover=coverage.clover
phpdbg -qrr -d memory_limit=-1 $HOME/.composer/vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.clover --exclude-group=timeout
else
phpunit -c phpunit.xml
fi

View File

@ -3,12 +3,6 @@
if [ $1 == 'before' ]; then
# Remove Xdebug from PHP runtime for all PHP version except 7.1 to speed up builds.
# We need Xdebug enabled in the PHP 7.1 build job as it is used to generate code coverage.
if [[ ${RUN_CODE_COVERAGE} != 1 ]]; then
phpenv config-rm xdebug.ini
fi
composer global require "phpunit/phpunit=6.*"
if [[ ${RUN_PHPCS} == 1 ]]; then

View File

@ -48,7 +48,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
* @param WC_Order $order Order to which the products should be added.
* @param array $prices Array of prices to use for created products. Leave empty for default prices.
*/
protected function add_products_to_order( $order, $prices = array() ) {
protected function add_products_to_order( &$order, $prices = array() ) {
// Remove previous items.
foreach ( $order->get_items() as $item ) {
$order->remove_item( $item->get_id() );
@ -70,7 +70,6 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
$prod_count++;
}
}
/**
@ -148,7 +147,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
$wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations" );
WC_Helper_Order::delete_order( $this->order->get_id() );
unset( $this->products, $this->order );
}
/**
@ -313,6 +312,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
/**
* Test for request_url() method.
*
* @group timeout
* @throws WC_Data_Exception
*/
public function test_request_url() {

View File

@ -11,9 +11,9 @@ class WC_Tests_Template_Functions extends WC_Unit_Test_Case {
/**
* Test wc_get_product_class().
*
* @covers wc_product_class()
* @covers wc_product_post_class()
* @covers wc_get_product_taxonomy_class()
* @covers ::wc_product_class()
* @covers ::wc_product_post_class()
* @covers ::wc_get_product_taxonomy_class()
* @since 3.4.0
*/
public function test_wc_get_product_class() {