mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:38:51 +08:00
Merge pull request #6 from runcommand/use-circle
Use Circle to run test suite
This commit is contained in:
commit
8d93154ef8
8 changed files with 47 additions and 32 deletions
29
.travis.yml
29
.travis.yml
|
@ -1,29 +0,0 @@
|
|||
sudo: false
|
||||
|
||||
language: php
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.6
|
||||
|
||||
cache:
|
||||
- composer
|
||||
- $HOME/.composer/cache
|
||||
|
||||
env:
|
||||
global:
|
||||
- WP_CLI_BIN_DIR=/tmp/wp-cli-phar
|
||||
|
||||
before_script:
|
||||
- bash bin/install-package-tests.sh
|
||||
|
||||
script: ./vendor/bin/behat
|
|
@ -3,7 +3,7 @@ runcommand/profile
|
|||
|
||||
Profile the performance of a WordPress request.
|
||||
|
||||
[](https://travis-ci.org/runcommand/profile)
|
||||
[](https://circleci.com/gh/runcommand/profile/tree/master)
|
||||
|
||||
Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing)
|
||||
|
||||
|
|
15
circle.yml
Normal file
15
circle.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
machine:
|
||||
php:
|
||||
version: 5.6.14
|
||||
environment:
|
||||
WP_CLI_BIN_DIR: /tmp/wp-cli-phar
|
||||
|
||||
dependencies:
|
||||
cache_directories:
|
||||
- ~/.composer/cache
|
||||
|
||||
test:
|
||||
pre:
|
||||
- bash bin/install-package-tests.sh
|
||||
override:
|
||||
- ./vendor/bin/behat --strict
|
|
@ -119,6 +119,11 @@ class FeatureContext extends BehatContext implements ClosuredContextInterface {
|
|||
}
|
||||
}
|
||||
|
||||
// Remove WP-CLI package directory
|
||||
if ( isset( $this->variables['PACKAGE_PATH'] ) ) {
|
||||
$this->proc( Utils\esc_cmd( 'rm -rf %s', $this->variables['PACKAGE_PATH'] ) )->run();
|
||||
}
|
||||
|
||||
foreach ( $this->running_procs as $proc ) {
|
||||
self::terminate_proc( $proc );
|
||||
}
|
||||
|
|
|
@ -8,6 +8,12 @@ function assertEquals( $expected, $actual ) {
|
|||
}
|
||||
}
|
||||
|
||||
function assertNotEquals( $expected, $actual ) {
|
||||
if ( $expected == $actual ) {
|
||||
throw new Exception( "Actual value: " . var_export( $actual, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
function assertNumeric( $actual ) {
|
||||
if ( !is_numeric( $actual ) ) {
|
||||
throw new Exception( "Actual value: " . var_export( $actual, true ) );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
function wp_mail() {
|
||||
// do nothing
|
||||
function wp_mail( $to ) {
|
||||
// Log for testing purposes
|
||||
WP_CLI::log( "WP-CLI test suite: Sent email to {$to}." );
|
||||
}
|
||||
|
||||
|
|
|
@ -190,3 +190,12 @@ $steps->Then( '/^the (.+) (file|directory) should (exist|not exist|be:|contain:|
|
|||
}
|
||||
);
|
||||
|
||||
$steps->Then( '/^an email should (be sent|not be sent)$/', function( $world, $expected ) {
|
||||
if ( 'be sent' === $expected ) {
|
||||
assertNotEquals( 0, $world->email_sends );
|
||||
} else if ( 'not be sent' === $expected ) {
|
||||
assertEquals( 0, $world->email_sends );
|
||||
} else {
|
||||
throw new Exception( 'Invalid expectation' );
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,6 +14,11 @@ function invoke_proc( $proc, $mode ) {
|
|||
return $proc->$method();
|
||||
}
|
||||
|
||||
function capture_email_sends( $stdout ) {
|
||||
$stdout = preg_replace( '#WP-CLI test suite: Sent email to.+\n?#', '', $stdout, -1, $email_sends );
|
||||
return array( $stdout, $email_sends );
|
||||
}
|
||||
|
||||
$steps->When( '/^I launch in the background `([^`]+)`$/',
|
||||
function ( $world, $cmd ) {
|
||||
$world->background_proc( $cmd );
|
||||
|
@ -24,6 +29,7 @@ $steps->When( '/^I (run|try) `([^`]+)`$/',
|
|||
function ( $world, $mode, $cmd ) {
|
||||
$cmd = $world->replace_variables( $cmd );
|
||||
$world->result = invoke_proc( $world->proc( $cmd ), $mode );
|
||||
list( $world->result->stdout, $world->email_sends ) = capture_email_sends( $world->result->stdout );
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -31,6 +37,7 @@ $steps->When( "/^I (run|try) `([^`]+)` from '([^\s]+)'$/",
|
|||
function ( $world, $mode, $cmd, $subdir ) {
|
||||
$cmd = $world->replace_variables( $cmd );
|
||||
$world->result = invoke_proc( $world->proc( $cmd, array(), $subdir ), $mode );
|
||||
list( $world->result->stdout, $world->email_sends ) = capture_email_sends( $world->result->stdout );
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -41,6 +48,7 @@ $steps->When( '/^I (run|try) the previous command again$/',
|
|||
|
||||
$proc = Process::create( $world->result->command, $world->result->cwd, $world->result->env );
|
||||
$world->result = invoke_proc( $proc, $mode );
|
||||
list( $world->result->stdout, $world->email_sends ) = capture_email_sends( $world->result->stdout );
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue