Skip to content

Commit 1f0d27a

Browse files
committed
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
2 parents 1aaae85 + 4e850f1 commit 1f0d27a

File tree

10 files changed

+29
-30
lines changed

10 files changed

+29
-30
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ dependencies.lock
9696
managed_components
9797

9898
# pytest log
99+
pytest-embedded/
100+
# legacy one
99101
pytest_embedded_log/
100102
list_job*.txt
101103
size_info*.txt

.gitlab/ci/host-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ test_pytest_qemu:
298298
artifacts:
299299
paths:
300300
- XUNIT_RESULT.xml
301-
- pytest_embedded_log/
301+
- pytest-embedded/
302302
reports:
303303
junit: XUNIT_RESULT.xml
304304
allow_failure: true # IDFCI-1752
@@ -332,7 +332,7 @@ test_pytest_linux:
332332
artifacts:
333333
paths:
334334
- XUNIT_RESULT.xml
335-
- pytest_embedded_log/
335+
- pytest-embedded/
336336
- "**/build*/build_log.txt"
337337
reports:
338338
junit: XUNIT_RESULT.xml

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ repos:
103103
name: Check type annotations in python files
104104
entry: tools/ci/check_type_comments.py
105105
additional_dependencies:
106-
- 'mypy==0.940'
107-
- 'mypy-extensions==0.4.3'
108-
- 'types-setuptools==57.4.14'
109-
- 'types-PyYAML==0.1.9'
106+
- 'mypy'
107+
- 'mypy-extensions'
108+
- 'types-setuptools'
109+
- 'types-PyYAML'
110110
- 'types-requests'
111111
exclude: >
112112
(?x)^(

conftest.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import typing as t
2626
import zipfile
2727
from copy import deepcopy
28-
from datetime import datetime
2928
from urllib.parse import quote
3029

3130
import common_test_methods # noqa: F401
@@ -40,7 +39,8 @@
4039
from idf_ci.app import import_apps_from_txt
4140
from idf_ci.uploader import AppDownloader, AppUploader
4241
from idf_ci_utils import IDF_PATH, idf_relpath
43-
from idf_pytest.constants import DEFAULT_SDKCONFIG, ENV_MARKERS, SPECIAL_MARKERS, TARGET_MARKERS, PytestCase
42+
from idf_pytest.constants import DEFAULT_SDKCONFIG, ENV_MARKERS, SPECIAL_MARKERS, TARGET_MARKERS, PytestCase, \
43+
DEFAULT_LOGDIR
4444
from idf_pytest.plugin import IDF_PYTEST_EMBEDDED_KEY, ITEM_PYTEST_CASE_KEY, IdfPytestEmbedded
4545
from idf_pytest.utils import format_case_id
4646
from pytest_embedded.plugin import multi_dut_argument, multi_dut_fixture
@@ -56,15 +56,10 @@ def idf_path() -> str:
5656
return os.path.dirname(__file__)
5757

5858

59-
@pytest.fixture(scope='session', autouse=True)
60-
def session_tempdir() -> str:
61-
_tmpdir = os.path.join(
62-
os.path.dirname(__file__),
63-
'pytest_embedded_log',
64-
datetime.now().strftime('%Y-%m-%d_%H-%M-%S'),
65-
)
66-
os.makedirs(_tmpdir, exist_ok=True)
67-
return _tmpdir
59+
@pytest.fixture(scope='session')
60+
def session_root_logdir(idf_path: str) -> str:
61+
"""Session scoped log dir for pytest-embedded"""
62+
return idf_path
6863

6964

7065
@pytest.fixture
@@ -466,11 +461,12 @@ def pytest_runtest_makereport(item, call): # type: ignore
466461

467462
job_id = os.getenv('CI_JOB_ID', 0)
468463
url = os.getenv('CI_PAGES_URL', '').replace('esp-idf', '-/esp-idf')
469-
template = f'{url}/-/jobs/{job_id}/artifacts/pytest_embedded_log/{{}}'
464+
template = f'{url}/-/jobs/{job_id}/artifacts/{DEFAULT_LOGDIR}/{{}}'
470465
logs_files = []
471466

472467
def get_path(x: str) -> str:
473-
return x.split('pytest_embedded_log/', 1)[1]
468+
return x.split(f'{DEFAULT_LOGDIR}/', 1)[1]
469+
474470
if isinstance(_dut, list):
475471
logs_files.extend([template.format(get_path(d.logfile)) for d in _dut])
476472
dut_artifacts_url.append('{}:'.format(_dut[0].test_case_name))

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ addopts =
1313
--logfile-extension ".txt"
1414
--check-duplicates y
1515
--ignore-glob */managed_components/*
16-
--ignore pytest_embedded_log
16+
--ignore pytest-embedded
1717

1818
# ignore DeprecationWarning
1919
filterwarnings =

tools/ci/check_type_comments.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
44
# SPDX-License-Identifier: Apache-2.0
5-
65
import argparse
76
import subprocess
87
from sys import exit
@@ -30,7 +29,7 @@ def types_valid_ignored_rules(file_name): # type: (str) -> bool
3029
"""
3130
Run Mypy check with rules for ignore list on the given file, return TRUE if Mypy check passes
3231
"""
33-
mypy_exit_code = subprocess.call('mypy {} --allow-untyped-defs'.format(file_name), shell=True)
32+
mypy_exit_code = subprocess.call('mypy {} --python-version 3.8 --allow-untyped-defs'.format(file_name), shell=True)
3433
return not bool(mypy_exit_code)
3534

3635

tools/ci/dynamic_pipelines/templates/.dynamic_jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
artifacts:
6161
paths:
6262
- XUNIT_RESULT*.xml
63-
- pytest_embedded_log/
63+
- pytest-embedded/
6464
# Child pipeline reports won't be collected in the main one
6565
# https://gitlab.com/groups/gitlab-org/-/epics/8205
6666
# reports:

tools/ci/idf_ci_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from functools import cached_property
1212
from pathlib import Path
1313

14-
IDF_PATH = os.path.abspath(os.getenv('IDF_PATH', os.path.join(os.path.dirname(__file__), '..', '..')))
14+
IDF_PATH: str = os.path.abspath(os.getenv('IDF_PATH', os.path.join(os.path.dirname(__file__), '..', '..')))
1515

1616

1717
def get_submodule_dirs(full_path: bool = False) -> t.List[str]:

tools/ci/idf_pytest/constants.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4']
2020
PREVIEW_TARGETS: t.List[str] = [] # this PREVIEW_TARGETS excludes 'linux' target
2121
DEFAULT_SDKCONFIG = 'default'
22+
DEFAULT_LOGDIR = 'pytest-embedded'
2223

2324
TARGET_MARKERS = {
2425
'esp32': 'support esp32 target',
@@ -200,7 +201,7 @@ def targets(self) -> t.List[str]:
200201
for _t in [app.target for app in self.apps]:
201202
if _t in self.target_markers:
202203
skip = False
203-
warnings.warn(f'`pytest.mark.[TARGET]` defined in parametrize for multi-dut test cases is deprecated. '
204+
warnings.warn(f'`pytest.mark.[TARGET]` defined in parametrize for multi-dut test cases is deprecated. ' # noqa: W604
204205
f'Please use parametrize instead for test case {self.item.nodeid}')
205206
break
206207

@@ -233,7 +234,7 @@ def _get_temp_markers_disabled_targets(marker_name: str) -> t.Set[str]:
233234
# temp markers should always use keyword arguments `targets` and `reason`
234235
if not temp_marker.kwargs.get('targets') or not temp_marker.kwargs.get('reason'):
235236
raise ValueError(
236-
f'`{marker_name}` should always use keyword arguments `targets` and `reason`. '
237+
f'`{marker_name}` should always use keyword arguments `targets` and `reason`. ' # noqa: W604
237238
f'For example: '
238239
f'`@pytest.mark.{marker_name}(targets=["esp32"], reason="IDF-xxxx, will fix it ASAP")`'
239240
)
@@ -292,7 +293,7 @@ def all_built_in_app_lists(self, app_lists: t.Optional[t.List[str]] = None) -> t
292293
bin_found[i] = 1
293294

294295
if sum(bin_found) == 0:
295-
msg = f'Skip test case {self.name} because all following binaries are not listed in the app lists: '
296+
msg = f'Skip test case {self.name} because all following binaries are not listed in the app lists: ' # noqa: E713
296297
for app in self.apps:
297298
msg += f'\n - {app.build_dir}'
298299

@@ -303,7 +304,7 @@ def all_built_in_app_lists(self, app_lists: t.Optional[t.List[str]] = None) -> t
303304
return None
304305

305306
# some found, some not, looks suspicious
306-
msg = f'Found some binaries of test case {self.name} are not listed in the app lists.'
307+
msg = f'Found some binaries of test case {self.name} are not listed in the app lists.' # noqa: E713
307308
for i, app in enumerate(self.apps):
308309
if bin_found[i] == 0:
309310
msg += f'\n - {app.build_dir}'

tools/ci/idf_pytest/tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
sys.path.append(tools_dir)
2020

2121
from idf_ci_utils import IDF_PATH # noqa: E402
22+
from idf_pytest.constants import DEFAULT_LOGDIR # noqa: E402
2223

2324

2425
def create_project(name: str, folder: Path) -> Path:
@@ -57,9 +58,9 @@ def create_project(name: str, folder: Path) -> Path:
5758

5859
@pytest.fixture
5960
def work_dirpath() -> t.Generator[Path, None, None]:
60-
os.makedirs(os.path.join(IDF_PATH, 'pytest_embedded_log'), exist_ok=True)
61+
os.makedirs(os.path.join(IDF_PATH, DEFAULT_LOGDIR), exist_ok=True)
6162

62-
p = Path(tempfile.mkdtemp(prefix=os.path.join(IDF_PATH, 'pytest_embedded_log') + os.sep))
63+
p = Path(tempfile.mkdtemp(prefix=os.path.join(IDF_PATH, DEFAULT_LOGDIR) + os.sep))
6364

6465
try:
6566
yield p

0 commit comments

Comments
 (0)