diff --git a/features/check.feature b/features/check.feature index 998e054..ba4eb00 100644 --- a/features/check.feature +++ b/features/check.feature @@ -185,3 +185,49 @@ Feature: Basic check usage And STDOUT should be a table containing rows: | name | status | | autoload-options-size | success | + + Scenario: Use --debug=doctor flag to see check progress + Given a WP install + + When I try `wp doctor check autoload-options-size --debug=doctor` + Then STDERR should contain: + """ + Running check: autoload-options-size + """ + And STDERR should contain: + """ + Status: + """ + + Scenario: Use --debug=doctor flag with multiple checks + Given a WP install + + When I try `wp doctor check autoload-options-size plugin-deactivated --debug=doctor` + Then STDERR should contain: + """ + Running check: autoload-options-size + """ + And STDERR should contain: + """ + Running check: plugin-deactivated + """ + + Scenario: Use --debug=doctor flag with file checks + Given a WP install + And a wp-content/plugins/foo.php file: + """ + run(); $completed[ $name ] = $check; if ( $progress ) { $progress->tick(); } + $results = $check->get_results(); + WP_CLI::debug( " Status: {$results['status']}", 'doctor' ); } ); } else { @@ -152,11 +160,17 @@ static function () use ( $name, $check, &$completed, &$progress ) { WP_CLI::add_hook( 'after_wp_config_load', static function () use ( $file_checks, &$completed, &$progress ) { + WP_CLI::debug( 'Scanning filesystem for file checks...', 'doctor' ); try { $directory = new RecursiveDirectoryIterator( ABSPATH, RecursiveDirectoryIterator::SKIP_DOTS ); $iterator = new RecursiveIteratorIterator( $directory, RecursiveIteratorIterator::CHILD_FIRST ); $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content'; + $item_count = 0; foreach ( $iterator as $file ) { + ++$item_count; + if ( 0 === $item_count % self::DEBUG_FILE_SCAN_INTERVAL ) { + WP_CLI::debug( " Visited {$item_count} items...", 'doctor' ); + } foreach ( $file_checks as $name => $check ) { $options = $check->get_options(); if ( ! empty( $options['only_wp_content'] ) @@ -174,15 +188,19 @@ static function () use ( $file_checks, &$completed, &$progress ) { $check->check_file( $file ); } } + WP_CLI::debug( " Total items visited: {$item_count}", 'doctor' ); } catch ( Exception $e ) { WP_CLI::warning( $e->getMessage() ); } foreach ( $file_checks as $name => $check ) { + WP_CLI::debug( "Running check: {$name}", 'doctor' ); $check->run(); $completed[ $name ] = $check; if ( $progress ) { $progress->tick(); } + $results = $check->get_results(); + WP_CLI::debug( " Status: {$results['status']}", 'doctor' ); } } );