mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 11:17:20 +02:00
Merge branch 'fix/pytest_session_dir_v5.3' into 'release/v5.3'
ci: apply new fix in pytest-embedded 1.10 (v5.3) See merge request espressif/esp-idf!30676
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -96,6 +96,8 @@ dependencies.lock
|
|||||||
managed_components
|
managed_components
|
||||||
|
|
||||||
# pytest log
|
# pytest log
|
||||||
|
pytest-embedded/
|
||||||
|
# legacy one
|
||||||
pytest_embedded_log/
|
pytest_embedded_log/
|
||||||
list_job*.txt
|
list_job*.txt
|
||||||
size_info*.txt
|
size_info*.txt
|
||||||
|
@ -298,7 +298,7 @@ test_pytest_qemu:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- XUNIT_RESULT.xml
|
- XUNIT_RESULT.xml
|
||||||
- pytest_embedded_log/
|
- pytest-embedded/
|
||||||
reports:
|
reports:
|
||||||
junit: XUNIT_RESULT.xml
|
junit: XUNIT_RESULT.xml
|
||||||
allow_failure: true # IDFCI-1752
|
allow_failure: true # IDFCI-1752
|
||||||
@ -332,7 +332,7 @@ test_pytest_linux:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- XUNIT_RESULT.xml
|
- XUNIT_RESULT.xml
|
||||||
- pytest_embedded_log/
|
- pytest-embedded/
|
||||||
- "**/build*/build_log.txt"
|
- "**/build*/build_log.txt"
|
||||||
reports:
|
reports:
|
||||||
junit: XUNIT_RESULT.xml
|
junit: XUNIT_RESULT.xml
|
||||||
|
@ -103,10 +103,10 @@ repos:
|
|||||||
name: Check type annotations in python files
|
name: Check type annotations in python files
|
||||||
entry: tools/ci/check_type_comments.py
|
entry: tools/ci/check_type_comments.py
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- 'mypy==0.940'
|
- 'mypy'
|
||||||
- 'mypy-extensions==0.4.3'
|
- 'mypy-extensions'
|
||||||
- 'types-setuptools==57.4.14'
|
- 'types-setuptools'
|
||||||
- 'types-PyYAML==0.1.9'
|
- 'types-PyYAML'
|
||||||
- 'types-requests'
|
- 'types-requests'
|
||||||
exclude: >
|
exclude: >
|
||||||
(?x)^(
|
(?x)^(
|
||||||
|
22
conftest.py
22
conftest.py
@ -25,7 +25,6 @@ import re
|
|||||||
import typing as t
|
import typing as t
|
||||||
import zipfile
|
import zipfile
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import datetime
|
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
import common_test_methods # noqa: F401
|
import common_test_methods # noqa: F401
|
||||||
@ -40,7 +39,8 @@ from dynamic_pipelines.constants import TEST_RELATED_APPS_DOWNLOAD_URLS_FILENAME
|
|||||||
from idf_ci.app import import_apps_from_txt
|
from idf_ci.app import import_apps_from_txt
|
||||||
from idf_ci.uploader import AppDownloader, AppUploader
|
from idf_ci.uploader import AppDownloader, AppUploader
|
||||||
from idf_ci_utils import IDF_PATH, idf_relpath
|
from idf_ci_utils import IDF_PATH, idf_relpath
|
||||||
from idf_pytest.constants import DEFAULT_SDKCONFIG, ENV_MARKERS, SPECIAL_MARKERS, TARGET_MARKERS, PytestCase
|
from idf_pytest.constants import DEFAULT_SDKCONFIG, ENV_MARKERS, SPECIAL_MARKERS, TARGET_MARKERS, PytestCase, \
|
||||||
|
DEFAULT_LOGDIR
|
||||||
from idf_pytest.plugin import IDF_PYTEST_EMBEDDED_KEY, ITEM_PYTEST_CASE_KEY, IdfPytestEmbedded
|
from idf_pytest.plugin import IDF_PYTEST_EMBEDDED_KEY, ITEM_PYTEST_CASE_KEY, IdfPytestEmbedded
|
||||||
from idf_pytest.utils import format_case_id
|
from idf_pytest.utils import format_case_id
|
||||||
from pytest_embedded.plugin import multi_dut_argument, multi_dut_fixture
|
from pytest_embedded.plugin import multi_dut_argument, multi_dut_fixture
|
||||||
@ -56,15 +56,10 @@ def idf_path() -> str:
|
|||||||
return os.path.dirname(__file__)
|
return os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session', autouse=True)
|
@pytest.fixture(scope='session')
|
||||||
def session_tempdir() -> str:
|
def session_root_logdir(idf_path: str) -> str:
|
||||||
_tmpdir = os.path.join(
|
"""Session scoped log dir for pytest-embedded"""
|
||||||
os.path.dirname(__file__),
|
return idf_path
|
||||||
'pytest_embedded_log',
|
|
||||||
datetime.now().strftime('%Y-%m-%d_%H-%M-%S'),
|
|
||||||
)
|
|
||||||
os.makedirs(_tmpdir, exist_ok=True)
|
|
||||||
return _tmpdir
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -466,11 +461,12 @@ def pytest_runtest_makereport(item, call): # type: ignore
|
|||||||
|
|
||||||
job_id = os.getenv('CI_JOB_ID', 0)
|
job_id = os.getenv('CI_JOB_ID', 0)
|
||||||
url = os.getenv('CI_PAGES_URL', '').replace('esp-idf', '-/esp-idf')
|
url = os.getenv('CI_PAGES_URL', '').replace('esp-idf', '-/esp-idf')
|
||||||
template = f'{url}/-/jobs/{job_id}/artifacts/pytest_embedded_log/{{}}'
|
template = f'{url}/-/jobs/{job_id}/artifacts/{DEFAULT_LOGDIR}/{{}}'
|
||||||
logs_files = []
|
logs_files = []
|
||||||
|
|
||||||
def get_path(x: str) -> str:
|
def get_path(x: str) -> str:
|
||||||
return x.split('pytest_embedded_log/', 1)[1]
|
return x.split(f'{DEFAULT_LOGDIR}/', 1)[1]
|
||||||
|
|
||||||
if isinstance(_dut, list):
|
if isinstance(_dut, list):
|
||||||
logs_files.extend([template.format(get_path(d.logfile)) for d in _dut])
|
logs_files.extend([template.format(get_path(d.logfile)) for d in _dut])
|
||||||
dut_artifacts_url.append('{}:'.format(_dut[0].test_case_name))
|
dut_artifacts_url.append('{}:'.format(_dut[0].test_case_name))
|
||||||
|
@ -13,7 +13,7 @@ addopts =
|
|||||||
--logfile-extension ".txt"
|
--logfile-extension ".txt"
|
||||||
--check-duplicates y
|
--check-duplicates y
|
||||||
--ignore-glob */managed_components/*
|
--ignore-glob */managed_components/*
|
||||||
--ignore pytest_embedded_log
|
--ignore pytest-embedded
|
||||||
|
|
||||||
# ignore DeprecationWarning
|
# ignore DeprecationWarning
|
||||||
filterwarnings =
|
filterwarnings =
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#
|
#
|
||||||
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
from sys import exit
|
from sys import exit
|
||||||
@ -30,7 +29,7 @@ def types_valid_ignored_rules(file_name): # type: (str) -> bool
|
|||||||
"""
|
"""
|
||||||
Run Mypy check with rules for ignore list on the given file, return TRUE if Mypy check passes
|
Run Mypy check with rules for ignore list on the given file, return TRUE if Mypy check passes
|
||||||
"""
|
"""
|
||||||
mypy_exit_code = subprocess.call('mypy {} --allow-untyped-defs'.format(file_name), shell=True)
|
mypy_exit_code = subprocess.call('mypy {} --python-version 3.8 --allow-untyped-defs'.format(file_name), shell=True)
|
||||||
return not bool(mypy_exit_code)
|
return not bool(mypy_exit_code)
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- XUNIT_RESULT*.xml
|
- XUNIT_RESULT*.xml
|
||||||
- pytest_embedded_log/
|
- pytest-embedded/
|
||||||
# Child pipeline reports won't be collected in the main one
|
# Child pipeline reports won't be collected in the main one
|
||||||
# https://gitlab.com/groups/gitlab-org/-/epics/8205
|
# https://gitlab.com/groups/gitlab-org/-/epics/8205
|
||||||
# reports:
|
# reports:
|
||||||
|
@ -11,7 +11,7 @@ import typing as t
|
|||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
IDF_PATH = os.path.abspath(os.getenv('IDF_PATH', os.path.join(os.path.dirname(__file__), '..', '..')))
|
IDF_PATH: str = os.path.abspath(os.getenv('IDF_PATH', os.path.join(os.path.dirname(__file__), '..', '..')))
|
||||||
|
|
||||||
|
|
||||||
def get_submodule_dirs(full_path: bool = False) -> t.List[str]:
|
def get_submodule_dirs(full_path: bool = False) -> t.List[str]:
|
||||||
|
@ -19,6 +19,7 @@ from pytest_embedded.utils import to_list
|
|||||||
SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4']
|
SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4']
|
||||||
PREVIEW_TARGETS: t.List[str] = [] # this PREVIEW_TARGETS excludes 'linux' target
|
PREVIEW_TARGETS: t.List[str] = [] # this PREVIEW_TARGETS excludes 'linux' target
|
||||||
DEFAULT_SDKCONFIG = 'default'
|
DEFAULT_SDKCONFIG = 'default'
|
||||||
|
DEFAULT_LOGDIR = 'pytest-embedded'
|
||||||
|
|
||||||
TARGET_MARKERS = {
|
TARGET_MARKERS = {
|
||||||
'esp32': 'support esp32 target',
|
'esp32': 'support esp32 target',
|
||||||
@ -200,7 +201,7 @@ class PytestCase:
|
|||||||
for _t in [app.target for app in self.apps]:
|
for _t in [app.target for app in self.apps]:
|
||||||
if _t in self.target_markers:
|
if _t in self.target_markers:
|
||||||
skip = False
|
skip = False
|
||||||
warnings.warn(f'`pytest.mark.[TARGET]` defined in parametrize for multi-dut test cases is deprecated. '
|
warnings.warn(f'`pytest.mark.[TARGET]` defined in parametrize for multi-dut test cases is deprecated. ' # noqa: W604
|
||||||
f'Please use parametrize instead for test case {self.item.nodeid}')
|
f'Please use parametrize instead for test case {self.item.nodeid}')
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ class PytestCase:
|
|||||||
# temp markers should always use keyword arguments `targets` and `reason`
|
# temp markers should always use keyword arguments `targets` and `reason`
|
||||||
if not temp_marker.kwargs.get('targets') or not temp_marker.kwargs.get('reason'):
|
if not temp_marker.kwargs.get('targets') or not temp_marker.kwargs.get('reason'):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f'`{marker_name}` should always use keyword arguments `targets` and `reason`. '
|
f'`{marker_name}` should always use keyword arguments `targets` and `reason`. ' # noqa: W604
|
||||||
f'For example: '
|
f'For example: '
|
||||||
f'`@pytest.mark.{marker_name}(targets=["esp32"], reason="IDF-xxxx, will fix it ASAP")`'
|
f'`@pytest.mark.{marker_name}(targets=["esp32"], reason="IDF-xxxx, will fix it ASAP")`'
|
||||||
)
|
)
|
||||||
@ -292,7 +293,7 @@ class PytestCase:
|
|||||||
bin_found[i] = 1
|
bin_found[i] = 1
|
||||||
|
|
||||||
if sum(bin_found) == 0:
|
if sum(bin_found) == 0:
|
||||||
msg = f'Skip test case {self.name} because all following binaries are not listed in the app lists: '
|
msg = f'Skip test case {self.name} because all following binaries are not listed in the app lists: ' # noqa: E713
|
||||||
for app in self.apps:
|
for app in self.apps:
|
||||||
msg += f'\n - {app.build_dir}'
|
msg += f'\n - {app.build_dir}'
|
||||||
|
|
||||||
@ -303,7 +304,7 @@ class PytestCase:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# some found, some not, looks suspicious
|
# some found, some not, looks suspicious
|
||||||
msg = f'Found some binaries of test case {self.name} are not listed in the app lists.'
|
msg = f'Found some binaries of test case {self.name} are not listed in the app lists.' # noqa: E713
|
||||||
for i, app in enumerate(self.apps):
|
for i, app in enumerate(self.apps):
|
||||||
if bin_found[i] == 0:
|
if bin_found[i] == 0:
|
||||||
msg += f'\n - {app.build_dir}'
|
msg += f'\n - {app.build_dir}'
|
||||||
|
@ -19,6 +19,7 @@ if tools_dir not in sys.path:
|
|||||||
sys.path.append(tools_dir)
|
sys.path.append(tools_dir)
|
||||||
|
|
||||||
from idf_ci_utils import IDF_PATH # noqa: E402
|
from idf_ci_utils import IDF_PATH # noqa: E402
|
||||||
|
from idf_pytest.constants import DEFAULT_LOGDIR # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
def create_project(name: str, folder: Path) -> Path:
|
def create_project(name: str, folder: Path) -> Path:
|
||||||
@ -57,9 +58,9 @@ void app_main(void) {}
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def work_dirpath() -> t.Generator[Path, None, None]:
|
def work_dirpath() -> t.Generator[Path, None, None]:
|
||||||
os.makedirs(os.path.join(IDF_PATH, 'pytest_embedded_log'), exist_ok=True)
|
os.makedirs(os.path.join(IDF_PATH, DEFAULT_LOGDIR), exist_ok=True)
|
||||||
|
|
||||||
p = Path(tempfile.mkdtemp(prefix=os.path.join(IDF_PATH, 'pytest_embedded_log') + os.sep))
|
p = Path(tempfile.mkdtemp(prefix=os.path.join(IDF_PATH, DEFAULT_LOGDIR) + os.sep))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield p
|
yield p
|
||||||
|
Reference in New Issue
Block a user