Skip to content

Commit 8d036f2

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'ci/attach_dut_log_url-v5.5' into 'release/v5.5'
ci: attach_log_url for multi dut tests See merge request espressif/esp-idf!43275
2 parents 2dc1a9b + dca7f49 commit 8d036f2

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

conftest.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,27 +380,33 @@ def set_dut_log_url(record_xml_attribute: t.Callable[[str, object], None], _pexp
380380
# Record the "dut_log_url" attribute in the XML report once test execution finished
381381
yield
382382

383-
if not isinstance(_pexpect_logfile, str):
384-
record_xml_attribute('dut_log_url', 'No log URL found')
385-
return
383+
def _attach_log_url_to_xml_attribute(log_file_path: str) -> str:
384+
if not isinstance(log_file_path, str):
385+
return 'No log URL found'
386386

387-
ci_pages_url = os.getenv('CI_PAGES_URL')
388-
logdir_pattern = re.compile(rf'({DEFAULT_LOGDIR}/.*)')
389-
match = logdir_pattern.search(_pexpect_logfile)
387+
ci_pages_url = os.getenv('CI_PAGES_URL')
388+
logdir_pattern = re.compile(rf'({DEFAULT_LOGDIR}/.*)')
389+
match = logdir_pattern.search(log_file_path)
390390

391-
if not match:
392-
record_xml_attribute('dut_log_url', 'No log URL found')
393-
return
391+
if not match:
392+
return 'No log URL found'
394393

395-
if not ci_pages_url:
396-
record_xml_attribute('dut_log_url', _pexpect_logfile)
397-
return
394+
if not ci_pages_url:
395+
return log_file_path
398396

399-
job_id = os.getenv('CI_JOB_ID', '0')
400-
modified_ci_pages_url = ci_pages_url.replace('esp-idf', '-/esp-idf')
401-
log_url = f'{modified_ci_pages_url}/-/jobs/{job_id}/artifacts/{match.group(1)}'
397+
job_id = os.getenv('CI_JOB_ID', '0')
398+
modified_ci_pages_url = ci_pages_url.replace('esp-idf', '-/esp-idf')
399+
log_url = f'{modified_ci_pages_url}/-/jobs/{job_id}/artifacts/{match.group(1)}'
402400

403-
record_xml_attribute('dut_log_url', log_url)
401+
return log_url
402+
403+
xml_attribute = []
404+
if isinstance(_pexpect_logfile, str):
405+
xml_attribute.append(_attach_log_url_to_xml_attribute(_pexpect_logfile))
406+
if isinstance(_pexpect_logfile, tuple):
407+
for i, log_file in enumerate(_pexpect_logfile):
408+
xml_attribute.append(_attach_log_url_to_xml_attribute(log_file))
409+
record_xml_attribute('dut_log_url', ';'.join(xml_attribute))
404410

405411

406412
######################

0 commit comments

Comments
 (0)