Skip to content

Commit

Permalink
Merge pull request #250 from woocommerce/25-02/add/more-deprecation-i…
Browse files Browse the repository at this point in the history
…gnoring

Filter deprecated query monitor logs in the CLI too
  • Loading branch information
singerb authored Feb 24, 2025
2 parents 7e68762 + 82ac68d commit 549d958
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/src/LocalTests/LocalTestRunNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function notify_test_finished( TestResult $test_result ): array {
if ( $use_query_monitor_logs ) {
$this->output->writeln( 'Parsing Query Monitor Logs' );

$debug_log['qm_logs'] = $this->prepare_qm_log->prepare_qm_logs( $results_dir );
$debug_log['qm_logs'] = $this->prepare_qm_log->prepare_qm_logs( $results_dir, App::getVar( E2EEnvInfo::class ) );
}

/**
Expand Down
10 changes: 1 addition & 9 deletions src/src/LocalTests/PrepareDebugLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,7 @@ public function prepare_debug_log( string $debug_log_file, string $new_debug_log
// Ignore a deprecation warning from Jetpack about itself.
$is_jetpack_geo_deprecation = stripos( $line, 'Class Jetpack_Geo_Location is' ) !== false;

// Ignore a deprecated core filter for now, since subs and payments both include it in shared code.
// Only if we're not testing one of those though.
$is_woocommerce_get_price_deprecation = stripos( $line, 'Use woocommerce_product_get_price instead' ) !== false;
$is_testing_payments_or_subs = in_array( $sut_slug, [ 'woocommerce-payments', 'woocommerce-subscriptions' ], true );

if (
$is_jetpack_geo_deprecation
|| ( $is_woocommerce_get_price_deprecation && ! $is_testing_payments_or_subs )
) {
if ( $is_jetpack_geo_deprecation ) {
continue;
}

Expand Down
20 changes: 17 additions & 3 deletions src/src/LocalTests/PrepareQMLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace QIT_CLI\LocalTests;

use QIT_CLI\Environment\Environments\E2E\E2EEnvInfo;

use Symfony\Component\Console\Output\OutputInterface;

class PrepareQMLog {
Expand Down Expand Up @@ -168,7 +170,7 @@ public function extract_error_info( array $lines ): array {
* @param string $directory
* @return array<string,mixed>
*/
public function summarize_qm_logs( string $directory ): array {
public function summarize_qm_logs( string $directory, string $sut_slug ): array {
$data = $this->read_json_data( $directory );
$summarized_data = [];

Expand All @@ -179,6 +181,17 @@ public function summarize_qm_logs( string $directory ): array {
foreach ( $data as $hash => $logs ) {
foreach ( $logs as $type => $type_logs ) {
foreach ( $type_logs as $info ) {
// Ignore some compatbility extension set issues.

// Ignore a deprecation warning from Jetpack about itself.
$is_jetpack_geo_deprecation = stripos( $info['message'], 'Class Jetpack_Geo_Location is' ) !== false;

if ( $is_jetpack_geo_deprecation ) {
continue;
}

// End compatibility extension set issues.

$info_summary = [
'message' => $info['message'],
'type' => $type,
Expand Down Expand Up @@ -247,11 +260,12 @@ public function summarize_debug_logs( string $file_path ): array {
* @param string $results_dir
* @return array<string,mixed>
*/
public function prepare_qm_logs( string $results_dir ): array {
public function prepare_qm_logs( string $results_dir, E2EEnvInfo $env_info ): array {
$sut_slug = $env_info->sut_slug;
$qm_logs_path = $results_dir . '/logs';
$debug_log_path = $results_dir . '/debug.log';
$debug_log = $this->summarize_debug_logs( $debug_log_path );
$qm_log = $this->summarize_qm_logs( $qm_logs_path );
$qm_log = $this->summarize_qm_logs( $qm_logs_path, $sut_slug );

if ( empty( $debug_log ) && empty( $qm_log ) ) {
return [];
Expand Down

0 comments on commit 549d958

Please sign in to comment.