def test_to_json_object_response(self):
     c = CompletedStructure('/a/source/dir', '/a/build/dir',
                            '/b/source/dir', '/b/build/dir', '/r/dir1',
                            '/r/dir2')
     t = TestEntry('filename', 'weather')
     t = TestTestEntry.fully_populated_entry_successful(t)
     c.add_test_entry(t)
     obj = c.to_json_summary()
     self.assertIn('directories', obj)
     self.assertIn('runs', obj)
     self.assertIn('diffs', obj)
     self.assertIn('results_by_file', obj)
    def diff_logs_for_build(self):

        completed_structure = CompletedStructure(
            self.build_tree_a['source_dir'], self.build_tree_a['build_dir'],
            self.build_tree_b['source_dir'], self.build_tree_b['build_dir'],
            os.path.join(self.build_tree_a['build_dir'], self.test_output_dir))
        for this_entry in self.entries:
            try:
                this_entry = self.process_diffs_for_one_case(this_entry)
                completed_structure.add_test_entry(this_entry)
            except Exception as e:  # pragma: no cover -- I'm not trying to catch every possible case here
                self.my_print((
                    "Unexpected error processing diffs for %s, could indicate an E+ crash caused corrupted files"
                ) % this_entry.basename)
                self.my_print("Message: %s" % e)
            finally:
                self.my_diffcompleted(this_entry.basename)
        return completed_structure
Example #3
0
 def test_to_csv(self):
     c = CompletedStructure('/a/source/dir', '/a/build/dir',
                            '/b/source/dir', '/b/build/dir', '/results/dir')
     t = TestEntry('filename', 'weather')
     t = TestTestEntry.fully_populated_entry_successful(t)
     c.add_test_entry(t)
     valid_temp_csv_file = tempfile.mkstemp(suffix='.csv')[1]
     c.to_runtime_summary(
         valid_temp_csv_file)  # not asserting anything, it should just pass
     with self.assertRaises(Exception):
         c.to_runtime_summary('/invalid/path')
Example #4
0
 def test_workflow(self):
     c = CompletedStructure('/a/source/dir', '/a/build/dir',
                            '/b/source/dir', '/b/build/dir', '/results/dir')
     t = TestEntry('filename', 'weather')
     t = TestTestEntry.fully_populated_entry_successful(t)
     c.add_test_entry(t)
     t = TestEntry('file_that_failed', 'weather')
     t = TestTestEntry.fully_populated_entry_failure(t)
     c.add_test_entry(t)
     t = TestEntry('filename', 'weather')
     t = TestTestEntry.fully_populated_entry_successful(t)
     t.add_table_differences(TableDifferences(
         [1, 1, 0, 1, 1, 1, 1, 1, 1]))  # override the table data
     c.add_test_entry(t)
 def on_button1_clicked(self, widget):
     results = CompletedStructure('/a/', '/b/', '/c/', '/d/', '/e/')
     this_entry = TestEntry('file.idf', 'file.epw')
     this_entry.add_summary_result(
         EndErrSummary(
             EndErrSummary.STATUS_SUCCESS,
             1,
             EndErrSummary.STATUS_SUCCESS,
             2
         ))
     results.add_test_entry(this_entry)
     root_and_files = {
         ResultsTreeRoots.NumRun: results.all_files,
         ResultsTreeRoots.Success1: results.success_case_a,
         ResultsTreeRoots.NotSuccess1: results.failure_case_a,
         ResultsTreeRoots.Success2: results.success_case_b,
         ResultsTreeRoots.NotSuccess2: results.failure_case_b,
         ResultsTreeRoots.FilesCompared: results.total_files_compared,
         ResultsTreeRoots.BigMath: results.big_math_diffs,
         ResultsTreeRoots.SmallMath: results.small_math_diffs,
         ResultsTreeRoots.BigTable: results.big_table_diffs,
         ResultsTreeRoots.SmallTable: results.small_table_diffs,
         ResultsTreeRoots.Textual: results.text_diffs
     }
     for tree_root in root_and_files:
         file_lists = root_and_files[tree_root]
         this_file_list_count = len(file_lists.descriptions)
         if self.results_child[tree_root]:  # pragma: no cover - I'd try to test this if the tree was its own class
             self.results_list_store.remove(self.results_child[tree_root])
         self.results_child[tree_root] = self.results_list_store.append(
             self.results_parent[tree_root],
             [str(this_file_list_count)]
         )
         this_path = self.results_list_store.get_path(self.results_parent[tree_root])
         self.tree_view.expand_row(this_path, False)
         for result in file_lists.descriptions:  # pragma: no cover
             self.results_list_store.append(self.results_child[tree_root], [result])
    def test_callback_handlers(self):
        # should add a message to the log
        prev_log_length = len(self.gui.log_store)
        self.gui.print_callback_handler('MyMessage')
        self.assertEqual(prev_log_length + 1, len(self.gui.log_store))

        # should prepare the progress bar length appropriately
        self.gui.sim_starting_callback_handler(number_of_builds=2,
                                               number_of_cases_per_build=9)
        self.assertEqual(self.gui.progress_maximum_value, 27)

        # mimic run button function
        self.gui.test_suite_is_running = True

        # should increment progress when a case is completed
        prev_progress = self.gui.current_progress_value
        tc = TestCaseCompleted('/run/', 'case_name', True, False, 'thread-1')
        self.gui.case_completed_callback_handler(tc)
        self.assertEqual(prev_progress + 1, self.gui.current_progress_value)

        # can also handle failure cases
        prev_progress = self.gui.current_progress_value
        tc = TestCaseCompleted('/run/', 'case_name', False, False, 'thread-1')
        self.gui.case_completed_callback_handler(tc)
        self.assertEqual(prev_progress + 1, self.gui.current_progress_value)

        # nothing to really check here, just make sure it passes
        self.gui.simulations_complete_callback_handler()

        # should again increment progress when a diff is completed for a case
        prev_progress = self.gui.current_progress_value
        self.gui.diff_completed_callback_handler('case_name')
        self.assertEqual(prev_progress + 1, self.gui.current_progress_value)

        # if the sim is cancelled, just make sure the flag is tidied up
        self.gui.cancel_callback_handler()
        self.assertFalse(self.gui.test_suite_is_running)

        # if it completes successfully, then we
        cs = CompletedStructure('/a/src', '/a/build', '/b/src', '/b/build',
                                '/results')
        self.gui.all_done_callback_handler(cs)
Example #7
0
 def test_to_json(self):
     c = CompletedStructure('/a/source/dir', '/a/build/dir',
                            '/b/source/dir', '/b/build/dir', '/results/dir')
     t = TestEntry('filename', 'weather')
     t = TestTestEntry.fully_populated_entry_successful(t)
     c.add_test_entry(t)
     valid_temp_json_file = tempfile.mkstemp(suffix='.json')[1]
     c.to_json_summary(valid_temp_json_file)
     with open(valid_temp_json_file) as f:
         json_body = f.read()
         obj = json.loads(json_body)
         self.assertIn('directories', obj)
         self.assertIn('runs', obj)
         self.assertIn('diffs', obj)
         self.assertIn('results_by_file', obj)