From 77146dfc4a75e298c0c13c2ba12929ae0a43ab07 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 11:17:50 -0300 Subject: [PATCH 1/7] Normalize bigger error logs to closest 25 --- _tests/tests/QITE2ETestCase.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/_tests/tests/QITE2ETestCase.php b/_tests/tests/QITE2ETestCase.php index 31fd09a0..a6981d1f 100644 --- a/_tests/tests/QITE2ETestCase.php +++ b/_tests/tests/QITE2ETestCase.php @@ -160,7 +160,8 @@ public function validate_and_normalize( string $file_path, ?callable $callback = * Normalization rules for 'count': * - Exact values are retained for counts below 50. * - Counts between 50 and 100 are rounded to the nearest 5. - * - Counts above 100 are rounded to the nearest 10. + * - Counts between 100 and 200 are rounded to the nearest 10. + * - Counts above 200 are rounded to the nearest 25. * * Additionally, certain known failure messages (e.g., WordPress.org connectivity issues) * are conditionally removed from the logs. @@ -175,7 +176,7 @@ public function validate_and_normalize( string $file_path, ?callable $callback = $debug_log['count'] = round( $debug_log['count'] / 5 ) * 5; // Round to the closest 5 if not already divisible by 5. echo "{$debug_log['count']}\n"; } - } else { + } elseif ( $debug_log['count'] < 200 ) { if ( $debug_log['count'] % 10 === 0 ) { echo "Skipping normalization as it's already divisible by 10\n"; } else { @@ -183,6 +184,14 @@ public function validate_and_normalize( string $file_path, ?callable $callback = $debug_log['count'] = round( $debug_log['count'] / 10 ) * 10; // Round to the closest 10 if not already divisible by 10. echo "{$debug_log['count']}\n"; } + } else { + if ( $debug_log['count'] % 25 === 0 ) { + echo "Skipping normalization as it's already divisible by 25\n"; + } else { + echo "Normalizing debug_log.count from {$debug_log['count']} to "; + $debug_log['count'] = round( $debug_log['count'] / 25 ) * 25; // Round to the closest 25 if not already divisible by 25. + echo "{$debug_log['count']}\n"; + } } // Handle E2E Delete Products tests with more wiggle room. From e00a5333c317449e9cc7f7b5c5b7ea20fa14ddd3 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 11:19:29 -0300 Subject: [PATCH 2/7] Simplify header --- _tests/QITSelfTests.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/_tests/QITSelfTests.php b/_tests/QITSelfTests.php index 98c39957..47015b6f 100644 --- a/_tests/QITSelfTests.php +++ b/_tests/QITSelfTests.php @@ -174,15 +174,25 @@ function generate_test_runs( array $test_types ): array { } function add_task_id_to_process( Process $process, array $test_run ) { - $task_id = sprintf( - "[Test Type %s [Slug %s] [PHP %s] [WP %s] [Woo %s] [Features %s])]: \n", - $test_run['type'], - $test_run['slug'], - $test_run['php'], - $test_run['wp'], - $test_run['woo'], - $test_run['features'] - ); + $task_id_parts = [ + sprintf( "[%s -", ucwords( $test_run['type'] ) ), + sprintf( "%s]", $test_run['slug'] ) + ]; + + if ( ! empty( $test_run['php'] ) ) { + $task_id_parts[] = sprintf( "[PHP %s]", $test_run['php'] ); + } + if ( ! empty( $test_run['wp'] ) ) { + $task_id_parts[] = sprintf( "[WP %s]", $test_run['wp'] ); + } + if ( ! empty( $test_run['woo'] ) ) { + $task_id_parts[] = sprintf( "[Woo %s]", $test_run['woo'] ); + } + if ( ! empty( $test_run['features'] ) ) { + $task_id_parts[] = sprintf( "[Features %s]", $test_run['features'] ); + } + + $task_id = implode( ' ', $task_id_parts ) . ": "; $process->setEnv( array_merge( $process->getEnv(), [ 'qit_task_id' => $task_id ] ) ); } From 385a041ab4408b32c8c99ffa83f5c7da8bd536c8 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 11:39:53 -0300 Subject: [PATCH 3/7] Add a summary section --- _tests/ParallelOutput.php | 48 ++++++++++++++++++++++++++++++++++++--- _tests/QITSelfTests.php | 5 ++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/_tests/ParallelOutput.php b/_tests/ParallelOutput.php index 47cd04ae..5748c307 100644 --- a/_tests/ParallelOutput.php +++ b/_tests/ParallelOutput.php @@ -5,10 +5,14 @@ class ParallelOutput { private $outputBuffer; private $headers; + private $processStatus; + private $startTimes; public function __construct() { - $this->outputBuffer = []; - $this->headers = []; + $this->outputBuffer = []; + $this->headers = []; + $this->processStatus = []; + $this->startTimes = []; register_shutdown_function( [ $this, 'onShutdown' ] ); } @@ -18,8 +22,9 @@ public function processOutputCallback( $out, Process $process ) { // Check and store the header for the task if ( ! isset( $this->headers[ $taskId ] ) ) { - $this->headers[ $taskId ] = $process->getEnv()['qit_task_id']; + $this->headers[ $taskId ] = $process->getEnv()['qit_task_id'] . "\n"; $this->outputBuffer[ $taskId ] = ""; + $this->startTimes[ $taskId ] = microtime( true ); } // Append new output to the buffer for the task @@ -28,6 +33,31 @@ public function processOutputCallback( $out, Process $process ) { if ( ! getenv( "CI" ) ) { $this->displayBufferedOutputs(); } + + $this->updateProcessStatus( $process, $out ); // You need to implement this method + } + + protected function updateProcessStatus( Process $process, $output ) { + $taskId = $process->getEnv()['qit_task_id']; + + if ( $process->isRunning() ) { + $status = "\u{1F3C3} Running..."; // Runner emoji + } elseif ( $process->isSuccessful() ) { + $status = "\u{2705} Success"; // Check mark emoji + } else { + $status = "\u{274C} Failed"; // Cross mark emoji + } + + // Format the status with time before storing it + $this->processStatus[ $taskId ] = $this->formatStatusWithTime( $taskId, $status ); + } + + protected function formatStatusWithTime( $taskId, $status ) { + $elapsed = microtime( true ) - $this->startTimes[ $taskId ]; + $minutes = floor( $elapsed / 60 ); + $seconds = str_pad( floor( $elapsed % 60 ), 2, '0', STR_PAD_LEFT ); + + return "[$minutes:$seconds] $taskId $status"; } protected function displayBufferedOutputs() { @@ -39,6 +69,12 @@ protected function displayBufferedOutputs() { echo "\033[1;33m" . $this->headers[ $taskId ] . "\033[0m"; // Yellow for headers echo $output . "\n"; } + + // Print the summary section + echo "\n\033[1;32mSummary Section:\033[0m\n"; // Green for summary section header + foreach ( $this->processStatus as $status ) { + echo "$status\n"; + } } public function onShutdown() { @@ -48,6 +84,12 @@ public function onShutdown() { echo "\033[1;33m" . $this->headers[ $taskId ] . "\033[0m\n"; // Yellow for headers echo $output; // Print the accumulated output } + + // Print the summary section + echo "\n\033[1;32mSummary Section:\033[0m\n"; // Green for summary section header + foreach ( $this->processStatus as $status ) { + echo "$status\n"; + } } } } diff --git a/_tests/QITSelfTests.php b/_tests/QITSelfTests.php index 47015b6f..af5fd3a6 100644 --- a/_tests/QITSelfTests.php +++ b/_tests/QITSelfTests.php @@ -407,9 +407,8 @@ function handle_qit_response( Process $qit_process, string $out, array &$failed_ // echo "[INFO] Preparing to run test: {$phpunit_process->getCommandLine()}\n"; try { - $phpunit_process->mustRun( function ( $type, $out ) use ( $phpunit_process ) { - $GLOBALS['parallelOutput']->processOutputCallback( $out, $phpunit_process ); - } ); + $phpunit_process->mustRun(); + $GLOBALS['parallelOutput']->processOutputCallback( $phpunit_process->getOutput(), $phpunit_process ); } catch ( ProcessFailedException $e ) { $failed_tests[] = $e; } finally { From 2316b06f233b704a7fa22e4d492d9ae3cca8fc8b Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 11:42:19 -0300 Subject: [PATCH 4/7] Change emoji --- _tests/ParallelOutput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tests/ParallelOutput.php b/_tests/ParallelOutput.php index 5748c307..8e123b8f 100644 --- a/_tests/ParallelOutput.php +++ b/_tests/ParallelOutput.php @@ -41,7 +41,7 @@ protected function updateProcessStatus( Process $process, $output ) { $taskId = $process->getEnv()['qit_task_id']; if ( $process->isRunning() ) { - $status = "\u{1F3C3} Running..."; // Runner emoji + $status = "\u{23F3} Running..."; // Running emoji } elseif ( $process->isSuccessful() ) { $status = "\u{2705} Success"; // Check mark emoji } else { From 8a12646b17a2aad4f4da5e2870a5b1ac9f80e2cf Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 11:52:58 -0300 Subject: [PATCH 5/7] Update API snapshots --- .../__snapshots__/ApiTest__test_api_valid_features_rc_74__1.php | 2 +- .../__snapshots__/ApiTest__test_api_valid_features_rc_82__1.php | 2 +- .../ApiTest__test_api_valid_features_stable_74__1.php | 2 +- .../ApiTest__test_api_valid_features_stable_82__1.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_74__1.php b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_74__1.php index 2e81a2b6..a6bf92f0 100644 --- a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_74__1.php +++ b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_74__1.php @@ -1381,7 +1381,7 @@ { "debug_log": [ { - "count": "560", + "count": "550", "message": "PHP Notice: New Product Editor is enabled as expected. in \\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php on line 12" } ] diff --git a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_82__1.php b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_82__1.php index 4f3652fa..2f78ae60 100644 --- a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_82__1.php +++ b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_rc_82__1.php @@ -1381,7 +1381,7 @@ { "debug_log": [ { - "count": "560", + "count": "550", "message": "PHP Notice: New Product Editor is enabled as expected. in \\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php on line 12" } ] diff --git a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_74__1.php b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_74__1.php index 2e81a2b6..a6bf92f0 100644 --- a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_74__1.php +++ b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_74__1.php @@ -1381,7 +1381,7 @@ { "debug_log": [ { - "count": "560", + "count": "550", "message": "PHP Notice: New Product Editor is enabled as expected. in \\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php on line 12" } ] diff --git a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_82__1.php b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_82__1.php index 4f3652fa..2f78ae60 100644 --- a/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_82__1.php +++ b/_tests/tests/__snapshots__/ApiTest__test_api_valid_features_stable_82__1.php @@ -1381,7 +1381,7 @@ { "debug_log": [ { - "count": "560", + "count": "550", "message": "PHP Notice: New Product Editor is enabled as expected. in \\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php on line 12" } ] From 4f79ea2140700b30fc24673bbbd2bcd11527fd44 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 12:29:37 -0300 Subject: [PATCH 6/7] Update E2E snapshot --- .../E2eTest__test_e2e_delete_products_stable_74__1.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_tests/tests/__snapshots__/E2eTest__test_e2e_delete_products_stable_74__1.php b/_tests/tests/__snapshots__/E2eTest__test_e2e_delete_products_stable_74__1.php index 9e9efc76..5e8d9f16 100644 --- a/_tests/tests/__snapshots__/E2eTest__test_e2e_delete_products_stable_74__1.php +++ b/_tests/tests/__snapshots__/E2eTest__test_e2e_delete_products_stable_74__1.php @@ -1585,6 +1585,14 @@ }, { "debug_log": [ + { + "count": "Less than 10", + "message": "PHP Notice: Function map_meta_cap was called incorrectly. When checking for the edit_post capability, you must always check it against a specific post. Please see Debugging in WordPress for more information. (This message was added in version 6.1.0.) in \\/var\\/www\\/html\\/wp-includes\\/functions.php on line 6031" + }, + { + "count": "Less than 10", + "message": "PHP Notice: Trying to get property \'ID\' of non-object in \\/var\\/www\\/html\\/wp-admin\\/includes\\/post.php on line 2132" + }, { "count": "Less than 10", "message": "PHP Notice: Trying to get property \'post_mime_type\' of non-object in \\/var\\/www\\/html\\/wp-admin\\/includes\\/post.php on line 273" From ef880c961168893e571b5170478e721f5ff455fa Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Wed, 20 Dec 2023 13:35:42 -0300 Subject: [PATCH 7/7] Fix deprecated --- _tests/ParallelOutput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tests/ParallelOutput.php b/_tests/ParallelOutput.php index 8e123b8f..91912f7b 100644 --- a/_tests/ParallelOutput.php +++ b/_tests/ParallelOutput.php @@ -55,7 +55,7 @@ protected function updateProcessStatus( Process $process, $output ) { protected function formatStatusWithTime( $taskId, $status ) { $elapsed = microtime( true ) - $this->startTimes[ $taskId ]; $minutes = floor( $elapsed / 60 ); - $seconds = str_pad( floor( $elapsed % 60 ), 2, '0', STR_PAD_LEFT ); + $seconds = str_pad( (int) ceil( $elapsed % 60 ), 2, '0', STR_PAD_LEFT ); return "[$minutes:$seconds] $taskId $status"; }