WordPress.org

Make WordPress Core

Changeset 40248


Ignore:
Timestamp:
03/08/2017 12:47:48 AM (5 years ago)
Author:
johnbillion
Message:

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.

Location:
branches/3.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9

  • branches/3.9/tests/phpunit/includes/testcase.php

    r27795 r40248  
    4848        $_POST = array();
    4949        $this->flush_cache();
     50    }
     51
     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        }
    5071    }
    5172
  • branches/3.9/tests/phpunit/tests/basic.php

    r32149 r40248  
    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 );
Note: See TracChangeset for help on using the changeset viewer.