mirror of
git://develop.git.wordpress.org/
synced 2025-04-14 17:12:13 +02:00
Build/Test Tools: Check if Travis/GitHub Actions environment variables are defined.
This adjusts the logic for determining whether to skip some tests when not in the primary branch, and allows for running these tests locally. Follow-up to [47000], [47001], [49264], [49267], [49280]. See #50401. git-svn-id: https://develop.svn.wordpress.org/trunk@49916 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ae989102e1
commit
fdc6fe26f2
@ -181,8 +181,8 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* Allow tests to be skipped on some automated runs.
|
||||
*
|
||||
* For test runs on Travis/GitHub Actions for something other than trunk/master, we want to skip tests that
|
||||
* only need to run for master.
|
||||
* For test runs on Travis/GitHub Actions for something other than trunk/master,
|
||||
* we want to skip tests that only need to run for master.
|
||||
*/
|
||||
public function skipOnAutomatedBranches() {
|
||||
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
|
||||
@ -193,14 +193,14 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
$github_event_name = getenv( 'GITHUB_EVENT_NAME' );
|
||||
$github_ref = getenv( 'GITHUB_REF' );
|
||||
|
||||
if ( 'false' !== $github_event_name ) {
|
||||
if ( $github_event_name && 'false' !== $github_event_name ) {
|
||||
// We're on GitHub Actions.
|
||||
$skipped = array( 'pull_request', 'pull_request_target' );
|
||||
|
||||
if ( in_array( $github_event_name, $skipped, true ) || 'refs/heads/master' !== $github_ref ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||
}
|
||||
} elseif ( 'false' !== $travis_branch ) {
|
||||
} elseif ( $travis_branch && 'false' !== $travis_branch ) {
|
||||
// We're on Travis CI.
|
||||
if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||
|
Loading…
x
Reference in New Issue
Block a user