Build/Test tools: In Travis, skip some tests when not on trunk.
This skips time sensitive tests (copyright year and PHP/MySQL version requirements) when tests are run on branches on Travis. Props netweb, jorbin Fixes #39486 Merges [40241] to the 4.4 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.4@40243 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
96d4ed69eb
commit
78223153bd
@ -148,6 +148,27 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
|||||||
$this->flush_cache();
|
$this->flush_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow tests to be skipped on some automated runs
|
||||||
|
*
|
||||||
|
* For test runs on Travis for something other than trunk/master
|
||||||
|
* we want to skip tests that only need to run for master.
|
||||||
|
*/
|
||||||
|
public function skipOnAutomatedBranches() {
|
||||||
|
// gentenv can be disabled
|
||||||
|
if ( ! function_exists( 'getenv' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
|
||||||
|
$travis_branch = getenv( 'TRAVIS_BRANCH' );
|
||||||
|
$travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
|
||||||
|
|
||||||
|
if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
|
||||||
|
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister existing post types and register defaults.
|
* Unregister existing post types and register defaults.
|
||||||
*
|
*
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
class Tests_Basic extends WP_UnitTestCase {
|
class Tests_Basic extends WP_UnitTestCase {
|
||||||
|
|
||||||
function test_license() {
|
function test_license() {
|
||||||
|
// This test is designed to only run on trunk/master
|
||||||
|
$this->skipOnAutomatedBranches();
|
||||||
|
|
||||||
$license = file_get_contents( ABSPATH . 'license.txt' );
|
$license = file_get_contents( ABSPATH . 'license.txt' );
|
||||||
preg_match( '#Copyright (\d+) by the contributors#', $license, $matches );
|
preg_match( '#Copyright (\d+) by the contributors#', $license, $matches );
|
||||||
$this_year = date( 'Y' );
|
$this_year = date( 'Y' );
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
class Tests_External_HTTP_Basic extends WP_UnitTestCase {
|
class Tests_External_HTTP_Basic extends WP_UnitTestCase {
|
||||||
|
|
||||||
function test_readme() {
|
function test_readme() {
|
||||||
|
// This test is designed to only run on trunk/master
|
||||||
|
$this->skipOnAutomatedBranches();
|
||||||
|
|
||||||
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
||||||
preg_match( '#<br /> Version (.*)#', $readme, $matches );
|
preg_match( '#<br /> Version (.*)#', $readme, $matches );
|
||||||
list( $version ) = explode( '-', $GLOBALS['wp_version'] );
|
list( $version ) = explode( '-', $GLOBALS['wp_version'] );
|
||||||
|
Loading…
Reference in New Issue
Block a user