From df11fb859352222ece52bec0930042cd410d9c59 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 10 Nov 2014 14:48:28 +0000 Subject: [PATCH] Exclude external-http tests when running `phpunit`. The external-http tests are very slow, and `Wp_Http` functionality is fairly isolated, so the benefits of skipping these tests by default outweigh the risks. A `grunt phpunit:external-http` subtask has been added, to ensure that the tests are executed during exhaustive runs of the test suite, such as in continuous integration. Fixes #30304. git-svn-id: https://develop.svn.wordpress.org/trunk@30298 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 6 +++++- phpunit.xml.dist | 1 + tests/phpunit/includes/bootstrap.php | 30 ++++++++++++++++++---------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 01d6a143ae..bcfdd7523e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -328,6 +328,10 @@ module.exports = function(grunt) { multisite: { cmd: 'phpunit', args: ['-c', 'tests/phpunit/multisite.xml'] + }, + 'external-http': { + cmd: 'phpunit', + args: ['-c', 'phpunit.xml.dist', '--group', 'external-http'] } }, uglify: { @@ -482,7 +486,7 @@ module.exports = function(grunt) { 'uglify:core', 'uglify:jqueryui', 'concat:tinymce', 'compress:tinymce', 'clean:tinymce', 'jsvalidate:build']); // Testing tasks. - grunt.registerMultiTask('phpunit', 'Runs PHPUnit tests, including the ajax and multisite tests.', function() { + grunt.registerMultiTask('phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() { grunt.util.spawn({ cmd: this.data.cmd, args: this.data.args, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index abf5f00059..6f9dd226d8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,6 +20,7 @@ ajax + external-http diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index c70c6d65e7..575954bb52 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -128,13 +128,18 @@ class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt { } } - $ajax_message = true; - $ms_files_message = true; + $skipped_groups = array( + 'ajax' => true, + 'ms-files' => true, + 'external-http' => true, + ); + foreach ( $options as $option ) { switch ( $option[0] ) { case '--exclude-group' : - $ajax_message = false; - $ms_files_message = false; + foreach ( $skipped_groups as $group_name => $skipped ) { + $skipped_groups[ $group_name ] = false; + } continue 2; case '--group' : $groups = explode( ',', $option[1] ); @@ -143,16 +148,19 @@ class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt { WP_UnitTestCase::forceTicket( $group ); } } - $ajax_message = ! in_array( 'ajax', $groups ); - $ms_files_message = ! in_array( 'ms-files', $groups ); + + foreach ( $skipped_groups as $group_name => $skipped ) { + if ( in_array( $group_name, $groups ) ) { + $skipped_groups[ $group_name ] = false; + } + } continue 2; } } - if ( $ajax_message ) { - echo "Not running ajax tests... To execute these, use --group ajax." . PHP_EOL; - } - if ( $ms_files_message ) { - echo "Not running ms_files_rewriting tests... To execute these, use --group ms-files." . PHP_EOL; + + $skipped_groups = array_filter( $skipped_groups ); + foreach ( $skipped_groups as $group_name => $skipped ) { + echo sprintf( 'Not running %1$s tests. To execute these, use --group %1$s.', $group_name ) . PHP_EOL; } } }