Ejemplo n.º 1
0
 public static function merge_test_results_process(&$result_file_writer, &$files_to_combine, $pass_attributes = null)
 {
     $test_result_manager = new pts_result_file_merge_manager($pass_attributes);
     $has_written_suite_info = false;
     $result_files = array();
     $result_merge_selects = array();
     foreach ($files_to_combine as &$file) {
         if (is_object($file) && $file instanceof pts_result_merge_select) {
             $result_merge_select = $file;
             $this_result_file = $result_merge_select->get_result_file();
             if ($this_result_file instanceof pts_result_file == false) {
                 $this_result_file = new pts_result_file($this_result_file);
             }
         } else {
             if (is_object($file) && $file instanceof pts_result_file) {
                 if (($t = $file->read_extra_attribute('rename_result_identifier')) != false) {
                     // This code path is currently used by Phoromatic
                     $result_merge_select = new pts_result_merge_select(null, null);
                     $result_merge_select->rename_identifier($t);
                 } else {
                     $result_merge_select = null;
                 }
                 $this_result_file = $file;
             } else {
                 $result_merge_select = new pts_result_merge_select($file, null);
                 $this_result_file = new pts_result_file($result_merge_select->get_result_file());
             }
         }
         if ($this_result_file->get_test_count() == 0) {
             // No reason to print the system information if there are no contained results
             continue;
         }
         array_push($result_files, $this_result_file);
         array_push($result_merge_selects, $result_merge_select);
     }
     if (!isset($pass_attributes['only_render_results_xml']) && ($result_file_count = count($result_files)) > 0) {
         for ($i = $result_file_count - 1; $i >= 0; $i--) {
             $new_title = isset($pass_attributes['new_result_file_title']) && !empty($pass_attributes['new_result_file_title']) ? $pass_attributes['new_result_file_title'] : null;
             $ret = $result_file_writer->add_result_file_meta_data($result_files[$i], null, $new_title, null);
             if ($ret) {
                 break;
             }
         }
     }
     foreach ($result_files as $i => &$result_file) {
         if (!isset($pass_attributes['only_render_results_xml'])) {
             $result_file_writer->add_system_information_from_result_file($result_file, $result_merge_selects[$i]);
         }
         $r = $result_file->get_result_objects();
         //$r = array_reverse($r);
         $test_result_manager->add_test_result_set($r, $result_merge_selects[$i]);
     }
     // Write the actual test results
     $result_file_writer->add_results_from_result_manager($test_result_manager);
 }
 public static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     $rename_identifier = pts_user_io::prompt_text_menu('Select the test run to rename', $result_file_identifiers);
     $rename_identifier_new = pts_user_io::prompt_user_input('Enter the new identifier');
     $merge_selects = array();
     foreach ($result_file_identifiers as $identifier) {
         $this_merge_select = new pts_result_merge_select($result, $identifier);
         if ($identifier == $rename_identifier && $rename_identifier != $rename_identifier_new) {
             $this_merge_select->rename_identifier($rename_identifier_new);
         }
         array_push($merge_selects, $this_merge_select);
     }
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier)) {
             rename(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier, PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier_new);
         }
     }
     $extract_result = pts_merge::merge_test_results_array($merge_selects);
     pts_client::save_test_result($r[0] . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public function merge($result_merges_to_combine, $pass_attributes = 0)
 {
     if (!is_array($result_merges_to_combine) || empty($result_merges_to_combine)) {
         return false;
     }
     foreach ($result_merges_to_combine as $i => &$merge_select) {
         if (!$merge_select instanceof $merge_select) {
             $merge_select = new pts_result_merge_select($merge_select);
         }
         if (!is_file($merge_select->get_result_file())) {
             if (defined('PTS_SAVE_RESULTS_PATH') && is_file(PTS_SAVE_RESULTS_PATH . $merge_select->get_result_file() . '/composite.xml')) {
                 $merge_select->set_result_file(PTS_SAVE_RESULTS_PATH . $merge_select->get_result_file() . '/composite.xml');
             } else {
                 unset($result_merges_to_combine[$i]);
             }
         }
     }
     if (empty($result_merges_to_combine)) {
         return false;
     }
     foreach ($result_merges_to_combine as &$merge_select) {
         $result_file = new pts_result_file($merge_select->get_result_file(), true);
         if ($merge_select->get_rename_identifier()) {
             $result_file->rename_run(null, $merge_select->get_rename_identifier());
         }
         $this->add_to_result_file($result_file);
         unset($result_file);
     }
 }