1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-21 02:26:10 +00:00

test(core): allow saving verbose log into a file

[no changelog]
This commit is contained in:
Roman Zeyde 2025-03-19 08:56:19 +02:00 committed by Roman Zeyde
parent abcbb5c2ab
commit b07ed98ba4
2 changed files with 16 additions and 2 deletions

View File

@ -55,13 +55,15 @@ jobs:
- run: |
# log serial console to file; sleep is used because tio needs stdin that is not /dev/null
nix-shell --arg hardwareTest true --run "sleep 8h | tio --timestamp --no-autoconnect /dev/ttyTREZOR &> trezor.log" &
nix-shell --run "poetry run pytest -v tests/device_tests $TESTOPTS"
nix-shell --run "poetry run pytest -v --verbose-log-file pytest.log tests/device_tests $TESTOPTS"
- run: tail -n50 trezor.log || true
if: failure()
- uses: actions/upload-artifact@v4
with:
name: core-hardware-${{ matrix.model }}-${{ matrix.coins }}
path: trezor.log
path: |
trezor.log
pytest.log
retention-days: 7
if: always()

View File

@ -16,6 +16,7 @@
from __future__ import annotations
import logging
import os
import typing as t
from enum import IntEnum
@ -441,6 +442,12 @@ def pytest_addoption(parser: "Parser") -> None:
choices=translations.LANGUAGES,
help="Run tests with a specified language: 'en' is the default",
)
parser.addoption(
"--verbose-log-file",
action="store",
default=None,
help="File path for verbose logging",
)
def pytest_configure(config: "Config") -> None:
@ -469,6 +476,11 @@ def pytest_configure(config: "Config") -> None:
if verbosity:
log.enable_debug_output(verbosity)
verbose_log_file = config.getoption("verbose_log_file")
if verbose_log_file:
handler = logging.FileHandler(verbose_log_file)
log.enable_debug_output(verbosity, handler)
idval_orig = IdMaker._idval_from_value
def idval_from_value(self: IdMaker, val: object) -> str | None: