Make WordPress Core

Changeset 40247


Ignore:
Timestamp:
03/08/2017 12:45:51 AM (10 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.0 branch.

Location:
branches/4.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

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

    r29503 r40247  
    6565                $_POST = array();
    6666                $this->flush_cache();
     67        }
     68
     69        /**
     70         * Allow tests to be skipped on some automated runs
     71         *
     72         * For test runs on Travis for something other than trunk/master
     73         * we want to skip tests that only need to run for master.
     74         */
     75        public function skipOnAutomatedBranches() {
     76                // gentenv can be disabled
     77                if ( ! function_exists( 'getenv' ) ) {
     78                        return false;
     79                }
     80
     81                // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
     82                $travis_branch       = getenv( 'TRAVIS_BRANCH' );
     83                $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
     84
     85                if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
     86                        $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     87                }
    6788        }
    6889
  • branches/4.0/tests/phpunit/tests/basic.php

    r32148 r40247  
    3030
    3131        function test_license() {
     32                // This test is designed to only run on trunk/master
     33                $this->skipOnAutomatedBranches();
     34
    3235                $license = file_get_contents( ABSPATH . 'license.txt' );
    3336                preg_match( '#Copyright (\d+) by the contributors#', $license, $matches );
Note: See TracChangeset for help on using the changeset viewer.