From db1e0ad281c2526ebb4caffc28c88e87c824cd71 Mon Sep 17 00:00:00 2001 From: deveco_test Date: Mon, 29 Aug 2022 12:01:00 +0800 Subject: [PATCH] =?UTF-8?q?fixed=203dfa93b=20from=20https://gitee.com/kuan?= =?UTF-8?q?jay/test=5Fxdevice/pulls/155=20=E4=BF=AE=E5=A4=8DOHJSUnit?= =?UTF-8?q?=E5=A4=9A=E6=B5=8B=E8=AF=95=E5=A5=97=E5=9C=BA=E6=99=AF=E4=B8=8B?= =?UTF-8?q?App=20Die=E6=97=B6=E7=94=A8=E4=BE=8B=E7=BB=9F=E8=AE=A1=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: deveco_test --- plugins/ohos/src/ohos/drivers/openharmony.py | 18 +++++++++++------- plugins/ohos/src/ohos/parser/parser.py | 15 +++++++++++---- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/ohos/src/ohos/drivers/openharmony.py b/plugins/ohos/src/ohos/drivers/openharmony.py index 6bf70e1..acccd89 100644 --- a/plugins/ohos/src/ohos/drivers/openharmony.py +++ b/plugins/ohos/src/ohos/drivers/openharmony.py @@ -251,7 +251,8 @@ class OHJSUnitTestDriver(IDriver): 0o755) self.config.device.execute_shell_command(command="hilog -r") with os.fdopen(hilog_open, "a") as hilog_file_pipe: - self.config.device.clear_crash_log() + if hasattr(self.config.device, "clear_crash_log"): + self.config.device.clear_crash_log() self.config.device.start_catch_device_log(hilog_file_pipe=hilog_file_pipe) self._run_oh_jsunit(config_file, request) except Exception as exception: @@ -264,7 +265,8 @@ class OHJSUnitTestDriver(IDriver): serial = "{}_{}".format(str(self.config.device.__get_serial__()), time.time_ns()) log_tar_file_name = "{}_{}".format(str(serial).replace( ":", "_"), request.get_module_name()) - self.config.device.start_get_crash_log(log_tar_file_name) + if hasattr(self.config.device, "start_get_crash_log"): + self.config.device.start_get_crash_log(log_tar_file_name) self.config.device.stop_catch_device_log() self.result = check_result_report( request.config.report_path, self.result, self.error_message) @@ -305,8 +307,9 @@ class OHJSUnitTestDriver(IDriver): oh_jsunit_para_parse(self.runner, self.config.testargs) test_to_run = self._collect_test_to_run() - LOG.info("Collected test count is: %s" % (len(test_to_run) - if test_to_run else 0)) + LOG.info("Collected test count is: {}, test count is: {}". + format(len(self.runner.expect_tests_dict.keys()), + len(test_to_run) if test_to_run else 0)) finally: do_module_kit_teardown(request) @@ -350,7 +353,7 @@ class OHJSUnitTestDriver(IDriver): self.rerun = True if is_rerun == 'true' else False if not package and not module: - raise ParamError("Neither package nor moodle is found" + raise ParamError("Neither package nor module is found" " in config file.", error_no="03201") timeout_config = get_config_value("shell-timeout", json_config.get_driver(), False) @@ -372,8 +375,9 @@ class OHJSUnitTestDriver(IDriver): def _do_test_run(self, listener): test_to_run = self._collect_test_to_run() - LOG.info("Collected test count is: %s" % (len(test_to_run) - if test_to_run else 0)) + LOG.info("Collected test count is: {}, test count is: {}". + format(len(self.runner.expect_tests_dict.keys()), + len(test_to_run) if test_to_run else 0)) if not test_to_run or not self.rerun: self.runner.run(listener) self.runner.notify_finished() diff --git a/plugins/ohos/src/ohos/parser/parser.py b/plugins/ohos/src/ohos/parser/parser.py index fae5dad..278dc11 100644 --- a/plugins/ohos/src/ohos/parser/parser.py +++ b/plugins/ohos/src/ohos/parser/parser.py @@ -1242,6 +1242,9 @@ class OHJSUnitTestParser(IParser): pos = self.runner.suite_recorder.get(suite.suite_name)[0] if len(test_des_list) == len(report_listener.result[pos][1]): continue + interval = len(test_des_list) - len(report_listener.result[pos][1]) + LOG.info("{} tests in {} had missed".format( + interval, suite.suite_name)) for test_des in test_des_list: is_contain = False for case in report_listener.result[pos][1]: @@ -1257,6 +1260,8 @@ class OHJSUnitTestParser(IParser): test_result.run_time = 0 test_result.code = ResultCode.BLOCKED.value report_listener.result[pos][1].append(test_result) + LOG.debug("Add {}#{}".format(test_des.class_name, + test_des.test_name)) def _handle_lacking_whole_suite(self, report_listener): all_suite_set = set(self.runner.expect_tests_dict.keys()) @@ -1265,13 +1270,15 @@ class OHJSUnitTestParser(IParser): suite_name_set = set() for suite in report_listener.suites.values(): suite_name_set.add(suite.suite_name) - un_suite_set.union(all_suite_set.difference(suite_name_set)) - for un_suite in un_suite_set: + un_suite_set = all_suite_set.difference(suite_name_set) + if un_suite_set: + LOG.info("{} suites had missed.".format(len(un_suite_set))) + for name in un_suite_set: test_des_list = self.runner.expect_tests_dict.get( - un_suite.suite_name, []) + name, []) current_suite = self.state_machine.suite(reset=True) current_suite.test_num = len(test_des_list) - current_suite.suite_name = self.current_value + current_suite.suite_name = name for listener in self.get_listeners(): suite = copy.copy(current_suite) listener.__started__(LifeCycle.TestSuite, suite)