mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 06:34:34 +02:00
Merge branch 'ci/raise_error_when_pytest_collect_failed' into 'master'
ci: raise exception when pytest collect failed See merge request espressif/esp-idf!16974
This commit is contained in:
@@ -87,8 +87,6 @@ def is_in_directory(file_path: str, folder: str) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def get_pytest_dirs(folder: str) -> List[str]:
|
def get_pytest_dirs(folder: str) -> List[str]:
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.nodes import Item
|
from _pytest.nodes import Item
|
||||||
|
|
||||||
@@ -102,11 +100,11 @@ def get_pytest_dirs(folder: str) -> List[str]:
|
|||||||
|
|
||||||
collector = CollectPlugin()
|
collector = CollectPlugin()
|
||||||
|
|
||||||
sys_stdout = sys.stdout
|
res = pytest.main(['--collect-only', '-q', folder], plugins=[collector])
|
||||||
sys.stdout = StringIO() # swallow the output
|
if res.value != 0:
|
||||||
pytest.main(['--collect-only', folder], plugins=[collector])
|
raise RuntimeError('pytest collection failed')
|
||||||
sys.stdout = sys_stdout # restore sys.stdout
|
|
||||||
|
|
||||||
|
sys.stdout.flush() # print instantly
|
||||||
test_file_paths = set(node.fspath for node in collector.nodes)
|
test_file_paths = set(node.fspath for node in collector.nodes)
|
||||||
|
|
||||||
return [os.path.dirname(file) for file in test_file_paths]
|
return [os.path.dirname(file) for file in test_file_paths]
|
||||||
|
Reference in New Issue
Block a user