diff --git a/conftest.py b/conftest.py index 8d06a4e..c9a929e 100644 --- a/conftest.py +++ b/conftest.py @@ -73,8 +73,6 @@ LN = "\n" class LabelType(Enum): - """用例级别对应报告级别""" - L1 = allure.severity_level.BLOCKER L2 = allure.severity_level.CRITICAL L3 = allure.severity_level.NORMAL @@ -82,12 +80,10 @@ class LabelType(Enum): def add_mark(item, name: str = "", args: tuple = (), kwargs: dict = None): - """add mark""" item.own_markers.append(Mark(name=name, args=args, kwargs=kwargs)) def write_json(session): - """write json""" return bool( session.config.option.send_pms and (session.config.option.task_id or session.config.option.suite_id) @@ -95,12 +91,10 @@ def write_json(session): def auto_send(session): - """auto send""" return bool(session.config.option.send_pms and session.config.option.trigger) def async_send(session): - """async send""" return bool( session.config.option.send_pms == ConfStr.ASYNC.value and session.config.option.trigger == ConfStr.AUTO.value @@ -108,7 +102,6 @@ def async_send(session): def finish_send(session): - """finish send""" return bool( session.config.option.send_pms == ConfStr.FINISH.value and session.config.option.trigger == ConfStr.AUTO.value @@ -152,7 +145,6 @@ def pytest_addoption(parser): def pytest_cmdline_main(config): - """pytest_cmdline_main""" # 初始化log配置,以解决allure报告日志格式问题 log_info = logger(config.option.log_level) config.option.log_level = config.option.log_level @@ -167,7 +159,6 @@ def pytest_addhooks(pluginmanager): @pytest.mark.trylast def pytest_configure(config): - """pytest_configure""" if hasattr(config, "workerinput"): return # xdist worker reporter = config.pluginmanager.getplugin("terminalreporter") @@ -178,29 +169,12 @@ def pytest_configure(config): def pytest_sessionstart(session): - """pytest_sessionstart""" - # if ( - # CmdCtl.run_cmd( - # "gsettings get com.deepin.dde.appearance gtk-theme", - # interrupt=False, - # out_debug_flag=False, - # command_log=False, - # ).strip("'") - # != GlobalConfig.SYS_THEME - # ): - # CmdCtl.run_cmd( - # f"gsettings set com.deepin.dde.appearance gtk-theme {GlobalConfig.SYS_THEME}", - # interrupt=False, - # out_debug_flag=False, - # command_log=False, - # ) _display = ( GlobalConfig.DisplayServer.wayland if GlobalConfig.IS_WAYLAND else GlobalConfig.DisplayServer.x11 ) logger.info(f"当前系统显示协议为 {_display.title()}") - # popen("gsettings set com.deepin.dde.dock position bottom") session.config.option.start_time = datetime.now() user = session.config.option.pms_user @@ -232,7 +206,6 @@ def pytest_sessionstart(session): @pytest.hookimpl(trylast=True) def pytest_generate_tests(metafunc): - """pytest generate tests""" repeat = metafunc.config.option.repeat marks = metafunc.definition.get_closest_marker("repeat") if marks is not None: @@ -252,8 +225,6 @@ def pytest_generate_tests(metafunc): def pytest_collection_modifyitems(session): - """pytest collection modifyitems""" - walk_dir = ( f"{GlobalConfig.APPS_PATH}/{session.config.option.app_name}" if session.config.option.app_name @@ -477,7 +448,6 @@ def pytest_collection_modifyitems(session): def pytest_collection_finish(session): - """pytest collection finish""" session.item_count = len(session.items) pop_skip_case_from_items = session.items[:] @@ -568,7 +538,6 @@ def pytest_collection_finish(session): def pytest_runtest_setup(item): - """pytest runtest setup""" if hasattr(item, "execution_count"): letmego.conf.setting.EXECUTION_COUNT = item.execution_count @@ -618,12 +587,10 @@ def pytest_runtest_setup(item): # pylint: disable=unused-argument def pytest_runtest_call(item): - """pytest runtest call""" logger.info(f"{FLAG_FEEL} case body {FLAG_FEEL}") def pytest_runtest_teardown(item): - """pytest runtest teardown""" logger.info(f"{FLAG_FEEL} teardown {FLAG_FEEL}") sessiontimeout = item.session.sessiontimeout if sessiontimeout: @@ -638,7 +605,6 @@ def pytest_runtest_teardown(item): @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_makereport(item, call): - """pytest_runtest_makereport""" out = yield report = out.get_result() if report.when == "setup": @@ -740,7 +706,6 @@ def pytest_runtest_makereport(item, call): def pytest_report_teststatus(report, config): - """pytest report teststatus""" # 在 setup 和 teardown 阶段处理 error 和 skip if report.when in ("setup", "teardown"): if report.failed: @@ -773,15 +738,14 @@ def pytest_report_teststatus(report, config): def pytest_sessionfinish(session): - """pytest session finish""" if session.config.option.allure_report_dir: AllureReportExtend.environment_info(session) - terminalreporter = session.config.pluginmanager.get_plugin("terminalreporter") + tr = session.config.pluginmanager.get_plugin("terminalreporter") execute = {} - for _, items in terminalreporter.stats.items(): + for _, items in tr.stats.items(): for item in items: - default_result = {"result": "blocked", "longrepr": "None"} - try: + if hasattr(item, "outcome"): + default_result = {"result": "blocked", "longrepr": "None"} if item.outcome == ConfStr.PASSED.value: default_result["result"] = "pass" elif item.outcome == ConfStr.SKIPPED.value: @@ -790,14 +754,13 @@ def pytest_sessionfinish(session): continue else: default_result["result"] = "fail" - item_name = item.nodeid.split("::")[0] + default_result["longrepr"] = item.longreprtext + item_name = item.fspath if not execute.get(item_name) or ( item.outcome != ConfStr.PASSED.value and execute.get(item_name).get("result") == "pass" ): execute[item_name] = default_result - except AttributeError: - pass if execute: with open(f"{GlobalConfig.ROOT_DIR}/ci_result.json", "w", encoding="utf-8") as _f: _f.write(dumps(execute, indent=2, ensure_ascii=False)) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 74e3b1c..be1c7de 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -24,7 +24,7 @@ export default withMermaid( themeConfig: { // https://vitepress.dev/reference/default-theme-config - siteTitle: "", + siteTitle: false, nav: [ {text: '指南', link: '/指南/简介/YouQu是什么'}, {text: '规划', link: '/规划/框架设计/AT基础框架设计方案'}, diff --git a/docs/规划/未来规划.md b/docs/规划/未来规划.md index 35f9acc..ad77148 100644 --- a/docs/规划/未来规划.md +++ b/docs/规划/未来规划.md @@ -1,6 +1,6 @@ # 未来规划 -## 桌面应用性能自动化测试 +## 🏌️‍♂️ 桌面应用性能自动化测试 ### 需优化解决的性能自动化问题 diff --git a/env_dev.sh b/env_dev.sh index 9d79cfa..1be54f9 100755 --- a/env_dev.sh +++ b/env_dev.sh @@ -35,6 +35,7 @@ env(){ deb_array[${#deb_array[@]}]=java-11-openjdk-headless deb_array[${#deb_array[@]}]=python3-tkinter deb_array[${#deb_array[@]}]=xdotool + deb_array[${#deb_array[@]}]=opencv fi for deb in ${deb_array[*]} @@ -87,6 +88,10 @@ if [ "${ENV_CUT_FLAG}" = "cut" ]; then ) fi +if [ ${debian_platform} == false ]; then + pip_array[${#pip_array[@]}]=numpy + fi + for p in ${pip_array[*]} do sudo pip3 install ${p} > /tmp/env.log 2>&1 diff --git a/setting/_env_base.sh b/setting/_env_base.sh index dfbfa64..dfff2a8 100644 --- a/setting/_env_base.sh +++ b/setting/_env_base.sh @@ -2,11 +2,10 @@ # SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. # SPDX-License-Identifier: GPL-2.0-only -tag=$(echo "$(cat ./CURRENT | grep "tag = ")" | cut -d "=" -f2 | python3 -c "s=input();print(s.strip())") -SETTING_DIR=`pwd` +SETTING_DIR=$(dirname $(realpath "${BASH_SOURCE[0]}")) ROOT_DIR=$(dirname ${SETTING_DIR}) - -config_pwd=$(cat ${ROOT_DIR}/setting/globalconfig.ini | grep "PASSWORD = ") +tag=$(echo "$(cat ${ROOT_DIR}/CURRENT | grep "tag = ")" | cut -d "=" -f2 | python3 -c "s=input();print(s.strip())") +config_pwd=$(cat ${ROOT_DIR}/setting/globalconfig.ini | grep -v "CLIENT_PASSWORD" | grep "PASSWORD = ") PASSWORD=$(echo "${config_pwd}" | cut -d "=" -f2 | python3 -c "s=input();print(s.strip())") while getopts ":p:" opt do diff --git a/setting/globalconfig.py b/setting/globalconfig.py index ae66e4f..08b80ce 100644 --- a/setting/globalconfig.py +++ b/setting/globalconfig.py @@ -8,10 +8,10 @@ from enum import Enum from enum import unique from getpass import getuser from os import popen -from os import getenv from os.path import abspath from os.path import dirname from os.path import join +from os.path import exists from platform import machine from time import strftime import pathlib @@ -201,13 +201,17 @@ class _GlobalConfig: END_DATE = log_cli.get("END_DATE", default="") # ====================== 动态获取变量 ====================== - version_cfg = GetCfg("/etc/os-version", "Version") - VERSION = (version_cfg.get("EditionName[zh_CN]") or "") + ( - version_cfg.get("MinorVersion") or "" - ) + VERSION = "" + if exists("/etc/os-version"): + version_cfg = GetCfg("/etc/os-version", "Version") + VERSION = (version_cfg.get("EditionName[zh_CN]") or "") + ( + version_cfg.get("MinorVersion") or "" + ) # IP HOST_IP = str(popen("hostname -I |awk '{print $1}'").read()).strip("\n").strip() - PRODUCT_INFO = popen("cat /etc/product-info").read() + PRODUCT_INFO = "" + if exists("cat /etc/product-info"): + PRODUCT_INFO = popen("cat /etc/product-info").read() # machine type # e.g. x86_64 SYS_ARCH = machine() diff --git a/setting/template/ci.json b/setting/template/ci.json index 66b3a5e..a1f1285 100644 --- a/setting/template/ci.json +++ b/setting/template/ci.json @@ -4,6 +4,7 @@ "line": "", "total": 0, "fail": 0, + "skip": 0, "block": 0, "pass": 0, "pass_rate": "" diff --git a/src/pms/pms2csv.py b/src/pms/pms2csv.py index 38ead72..9777d67 100644 --- a/src/pms/pms2csv.py +++ b/src/pms/pms2csv.py @@ -275,7 +275,7 @@ class Pms2Csv(_Base): new_csv_tags = new_csv_file_tags.get(csv_file) with open(csv_file, "w+", encoding="utf-8") as f: for tags in new_csv_tags: - f.write(",".join(tags) + "\n") + f.write(",".join(["" if i is None else i for i in tags]) + "\n") logger.info(f"同步完成: {csv_file}") diff --git a/src/rtk/local_runner.py b/src/rtk/local_runner.py index 3b54d07..dd3757a 100644 --- a/src/rtk/local_runner.py +++ b/src/rtk/local_runner.py @@ -439,23 +439,10 @@ class LocalRunner: passed = res.get("pass", 0) failed = total - passed pass_rate = f"{round((passed / total) * 100, 1)}%" if passed else "0%" - return total, failed, passed, pass_rate + return total, failed, passed, skiped, pass_rate @classmethod def write_json(cls, project_name=None, build_location=None, line=None): - """ - 写json报告 - { - "project_name": "", - "build_location": "", - "line": "", - "total": "", - "fail": "", - "block": "", - "pass": "", - "pass_rate": "" - } - """ json_tpl_path = f"{GlobalConfig.SETTING_PATH}/template/ci.json" if not exists(json_tpl_path): raise FileNotFoundError @@ -473,6 +460,7 @@ class LocalRunner: results["total"], results["fail"], results["pass"], + results["skip"], results["pass_rate"], ) = cls.get_result(ci_result_path)