From d60a577029191cfe737dc8be320983f6887c7892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=A4=AA?= Date: Mon, 10 Jul 2023 23:07:41 +1000 Subject: [PATCH] Don't clear results buffer between loops When tests or suites are looped with TOTAL_LOOP_COUNT or TOTAL_LOOP_TIME, each loop would produce an independent result entry with identical identifiers (descriptions). However, the results viewer and exporters silently ignore any results with duplicate identifiers. This change combines the results from all loops into a single result entry to avoid the issue. Note: This change may cause data loss in existing result files if they have multiple results with the same identifiers. But since those multiple results were never "visible" to users in the first place, it's not a practical issue. Fixes #735 --- .../objects/client/pts_test_execution.php | 2 -- pts-core/objects/pts_test_result.php | 3 +++ pts-core/objects/pts_test_result_buffer.php | 19 ++++++++----------- pts-core/objects/pts_test_result_parser.php | 1 - 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pts-core/objects/client/pts_test_execution.php b/pts-core/objects/client/pts_test_execution.php index c5a2da4436..0c73530a6c 100644 --- a/pts-core/objects/client/pts_test_execution.php +++ b/pts-core/objects/client/pts_test_execution.php @@ -68,8 +68,6 @@ public static function run_test(&$test_run_manager, &$test_run_request) return false; } - $test_run_request->active = new pts_test_result_buffer_active(); - $test_run_request->generated_result_buffers = array(); $execute_binary = $test_run_request->test_profile->get_test_executable(); $times_to_run = $test_run_request->test_profile->get_times_to_run(); $ignore_runs = $test_run_request->test_profile->get_runs_to_ignore(); diff --git a/pts-core/objects/pts_test_result.php b/pts-core/objects/pts_test_result.php index 2d68572f29..0a7ec6f296 100644 --- a/pts-core/objects/pts_test_result.php +++ b/pts-core/objects/pts_test_result.php @@ -49,6 +49,9 @@ class pts_test_result public function __construct($test_profile) { $this->test_profile = clone $test_profile; + + $this->active = new pts_test_result_buffer_active(); + $this->generated_result_buffers = array(); $this->test_run_times = array(); } public function get_estimated_run_time() diff --git a/pts-core/objects/pts_test_result_buffer.php b/pts-core/objects/pts_test_result_buffer.php index 1c4b3b0bba..30b8913ad7 100644 --- a/pts-core/objects/pts_test_result_buffer.php +++ b/pts-core/objects/pts_test_result_buffer.php @@ -51,26 +51,23 @@ public function __construct($buffer_items = array()) } public function add_buffer_item($buffer_item) { - if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()]) && $this->buffer_items[$this->buffer_by_identifier[$buffer_item->get_result_identifier()]]->get_result_value() == '') + if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()])) { - // Overwrite the buffer item if there is a match but empty (incomplete) result + // Overwrite the buffer item if there is an existing match $this->remove($buffer_item->get_result_identifier()); } - if(!$this->buffer_contained($buffer_item)) - { - $this->buffer_items[] = $buffer_item; - $this->buffer_by_identifier[$buffer_item->get_result_identifier()] = (count($this->buffer_items) - 1); - $this->buffer_contains[$buffer_item->get_result_identifier() . $buffer_item->get_result_value()] = 1; - $this->check_buffer_item_for_min_max($buffer_item); - } + $this->buffer_items[] = $buffer_item; + $this->buffer_by_identifier[$buffer_item->get_result_identifier()] = (count($this->buffer_items) - 1); + $this->buffer_contains[$buffer_item->get_result_identifier() . $buffer_item->get_result_value()] = 1; + $this->check_buffer_item_for_min_max($buffer_item); } public function add_test_result($identifier, $value, $raw_value = null, $json = null, $min_value = null, $max_value = null) { $buffer_item = new pts_test_result_buffer_item($identifier, $value, $raw_value, $json, $min_value, $max_value); - if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()]) && $this->buffer_items[$this->buffer_by_identifier[$buffer_item->get_result_identifier()]]->get_result_value() == '') + if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()])) { - // Overwrite the buffer item if there is a match but empty (incomplete) result + // Overwrite the buffer item if there is an existing match $this->remove($buffer_item->get_result_identifier()); } diff --git a/pts-core/objects/pts_test_result_parser.php b/pts-core/objects/pts_test_result_parser.php index 7579d48d6b..df0341e631 100644 --- a/pts-core/objects/pts_test_result_parser.php +++ b/pts-core/objects/pts_test_result_parser.php @@ -381,7 +381,6 @@ public static function generate_extra_data(&$test_result, &$test_log_file = null $tp->set_display_format('LINE_GRAPH'); $tp->set_identifier(null); $extra_result = new pts_test_result($tp); - $extra_result->active = new pts_test_result_buffer_active(); $extra_result->set_used_arguments_description($test_result->get_arguments_description() . ' - Total Frame Time'); $extra_result->set_used_arguments($test_result->get_arguments() . ' - ' . $extra_result->get_arguments_description()); // this formatting is weird but to preserve pre-PTS7 comparsions of extra results $extra_result->active->set_result(implode(',', $frame_all_times));