Skip to content

Commit 6e9b29e

Browse files
committed
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 3.9 branch. git-svn-id: https://develop.svn.wordpress.org/branches/3.9@40248 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f728859 commit 6e9b29e

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/phpunit/includes/testcase.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ function clean_up_global_scope() {
4949
$this->flush_cache();
5050
}
5151

52+
/**
53+
* Allow tests to be skipped on some automated runs
54+
*
55+
* For test runs on Travis for something other than trunk/master
56+
* we want to skip tests that only need to run for master.
57+
*/
58+
public function skipOnAutomatedBranches() {
59+
// gentenv can be disabled
60+
if ( ! function_exists( 'getenv' ) ) {
61+
return false;
62+
}
63+
64+
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
65+
$travis_branch = getenv( 'TRAVIS_BRANCH' );
66+
$travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
67+
68+
if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
69+
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
70+
}
71+
}
72+
5273
function flush_cache() {
5374
global $wp_object_cache;
5475
$wp_object_cache->group_ops = array();

tests/phpunit/tests/basic.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ function test_readme() {
3030
}
3131

3232
function test_license() {
33+
// This test is designed to only run on trunk/master
34+
$this->skipOnAutomatedBranches();
35+
3336
$license = file_get_contents( ABSPATH . 'license.txt' );
3437
preg_match( '#Copyright (\d+) by the contributors#', $license, $matches );
3538
$this_year = date( 'Y' );

0 commit comments

Comments
 (0)