def get_tests_runtimes(self): """Return the list of (test_file, runtime_in_secs) tuples ordered by decreasing runtime.""" tests = [] for test_file, runtime_info in self._runtime_by_test.items(): duration = runtime_info["duration"] test_name = testname.get_short_name_from_test_file(test_file) hook_runtime_info = self._hook_runtime_by_test[test_name] if hook_runtime_info: duration += hook_runtime_info["duration"] tests.append((normalize_test_name(test_file), duration)) return sorted(tests, key=lambda x: x[1], reverse=True)
def get_tests_runtimes(self): """Return the list of (test_file, runtime_in_secs) tuples ordered by decreasing runtime.""" tests = [] for test_file, runtime_info in self._runtime_by_test.items(): duration = runtime_info["duration"] test_name = testname.get_short_name_from_test_file(test_file) hook_runtime_info = self._hook_runtime_by_test[test_name] if hook_runtime_info: duration += hook_runtime_info["duration"] tests.append((normalize_test_name(test_file), duration)) return sorted(tests, key=lambda x: x[1], reverse=True)
def get_tests_runtimes(self) -> List[TestRuntime]: """Return the list of (test_file, runtime_in_secs) tuples ordered by decreasing runtime.""" tests = [] for test_file, runtime_info in list(self._runtime_by_test.items()): duration = runtime_info.duration test_name = testname.get_short_name_from_test_file(test_file) for _, hook_runtime_info in self._hook_runtime_by_test[test_name].items(): duration += hook_runtime_info.duration test = TestRuntime(test_name=normalize_test_name(test_file), runtime=duration) tests.append(test) return sorted(tests, key=lambda x: x.runtime, reverse=True)
def from_stats_list(cls, historic_stats: List[TestStats]) -> "HistoricTaskData": """ Build historic task data from a list of historic stats. :param historic_stats: List of historic stats to build from. :return: Historic task data from the list of stats. """ hooks = defaultdict(list) for hook in [ stat for stat in historic_stats if is_resmoke_hook(stat.test_file) ]: historical_hook = HistoricHookInfo.from_test_stats(hook) hooks[historical_hook.test_name()].append(historical_hook) return cls([ HistoricTestInfo.from_test_stats( stat, hooks[get_short_name_from_test_file(stat.test_file)]) for stat in historic_stats if not is_resmoke_hook(stat.test_file) ])
def test_full_path_and_extension_are_stripped(self): hook_name = testname_utils.get_short_name_from_test_file("path/to/test_file.sh") self.assertEqual(hook_name, "test_file")
def test_extension_is_not_returned(self): hook_name = testname_utils.get_short_name_from_test_file("test_file.sh") self.assertEqual(hook_name, "test_file")
def test_only_base_name_is_returned(self): hook_name = testname_utils.get_short_name_from_test_file("path/to/test_file") self.assertEqual(hook_name, "test_file")