WordPress.org

Make WordPress Core

Changeset 40243


Ignore:
Timestamp:
03/08/2017 12:31:45 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 4.4 branch.

Location:
branches/4.4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

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

    r35350 r40243  
    147147        $_POST = array();
    148148        $this->flush_cache();
     149    }
     150
     151    /**
     152     * Allow tests to be skipped on some automated runs
     153     *
     154     * For test runs on Travis for something other than trunk/master
     155     * we want to skip tests that only need to run for master.
     156     */
     157    public function skipOnAutomatedBranches() {
     158        // gentenv can be disabled
     159        if ( ! function_exists( 'getenv' ) ) {
     160            return false;
     161        }
     162
     163        // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
     164        $travis_branch       = getenv( 'TRAVIS_BRANCH' );
     165        $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
     166
     167        if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
     168            $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     169        }
    149170    }
    150171
  • branches/4.4/tests/phpunit/tests/basic.php

    r35244 r40243  
    88
    99    function test_license() {
     10        // This test is designed to only run on trunk/master
     11        $this->skipOnAutomatedBranches();
     12
    1013        $license = file_get_contents( ABSPATH . 'license.txt' );
    1114        preg_match( '#Copyright (\d+) by the contributors#', $license, $matches );
  • branches/4.4/tests/phpunit/tests/external-http/basic.php

    r35172 r40243  
    66
    77    function test_readme() {
     8        // This test is designed to only run on trunk/master
     9        $this->skipOnAutomatedBranches();
     10
    811        $readme = file_get_contents( ABSPATH . 'readme.html' );
    912        preg_match( '#<br /> Version (.*)#', $readme, $matches );
Note: See TracChangeset for help on using the changeset viewer.