ci: different test case name with different params

This commit is contained in:
Fu Hanxi 2023-09-18 10:59:05 +02:00
parent e48ca24364
commit 24b2e0a56d
2 changed files with 16 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import logging
import os
import re
import sys
from copy import deepcopy
from datetime import datetime
from typing import Callable, Optional
@ -87,7 +88,17 @@ def test_func_name(request: FixtureRequest) -> str:
@pytest.fixture
def test_case_name(request: FixtureRequest, target: str, config: str) -> str:
is_qemu = request._pyfuncitem.get_closest_marker('qemu') is not None
return format_case_id(target, config, request.node.originalname, is_qemu=is_qemu) # type: ignore
if hasattr(request._pyfuncitem, 'callspec'):
params = deepcopy(request._pyfuncitem.callspec.params) # type: ignore
else:
params = {}
filtered_params = {}
for k, v in params.items():
if k not in request.session._fixturemanager._arg2fixturedefs: # type: ignore
filtered_params[k] = v # not fixture ones
return format_case_id(target, config, request.node.originalname, is_qemu=is_qemu, params=filtered_params) # type: ignore
@pytest.fixture

View File

@ -9,7 +9,7 @@ from xml.etree import ElementTree as ET
from .constants import TARGET_MARKERS
def format_case_id(target: t.Optional[str], config: t.Optional[str], case: str, is_qemu: bool = False) -> str:
def format_case_id(target: t.Optional[str], config: t.Optional[str], case: str, is_qemu: bool = False, params: t.Optional[dict] = None) -> str:
parts = []
if target:
parts.append((str(target) + '_qemu') if is_qemu else str(target))
@ -17,6 +17,9 @@ def format_case_id(target: t.Optional[str], config: t.Optional[str], case: str,
parts.append(str(config))
parts.append(case)
if params:
parts.append(str(params))
return '.'.join(parts)