diff --git a/features/profile-hook-feature.feature b/features/profile-hook-feature.feature index 56e5863..ba8432a 100644 --- a/features/profile-hook-feature.feature +++ b/features/profile-hook-feature.feature @@ -8,3 +8,14 @@ Feature: Profile a specific hook | callback | | total | And STDERR should be empty + + Scenario: Profile a hook that has actions with output + Given a WP install + + When I run `wp profile --hook=wp_head --fields=callback` + Then STDOUT should be a table containing rows: + | callback | + And STDOUT should not contain: + """ + load_wordpress_with_template(); - } catch( \Exception $e ) { - // pass through - } + $this->load_wordpress_with_template(); if ( $this->focus_stage ) { $fields = array( @@ -266,7 +262,11 @@ class Command { $logger = new Logger( 'stage', 'bootstrap' ); $logger->start(); } - WP_CLI::get_runner()->load_wordpress(); + try { + WP_CLI::get_runner()->load_wordpress(); + } catch( \Exception $e ) { + // pass through + } if ( ! $this->focus_stage && ! $this->focus_hook ) { $logger->stop(); $this->loggers[] = $logger; @@ -285,7 +285,11 @@ class Command { $logger = new Logger( 'stage', 'main_query' ); $logger->start(); } - wp(); + try { + wp(); + } catch( \Exception $e ) { + // pass through + } if ( ! $this->focus_stage && ! $this->focus_hook ) { $logger->stop(); $this->loggers[] = $logger; @@ -313,12 +317,17 @@ class Command { $logger->start(); } ob_start(); - require_once( ABSPATH . WPINC . '/template-loader.php' ); + try { + require_once( ABSPATH . WPINC . '/template-loader.php' ); + } catch( \Exception $e ) { + // pass through + } ob_get_clean(); if ( ! $this->focus_stage && ! $this->focus_hook ) { $logger->stop(); $this->loggers[] = $logger; } + } /**