mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-27 20:05:10 +00:00
BostFacade and UnitFacade saving the logs only when test failed, ignoring the -s parameter that should allow save logs on success. This PR adding checking this parameter. Closes scylladb/scylladb#24596
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
#
|
|
# Copyright (C) 2025-present ScyllaDB
|
|
#
|
|
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
#
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from typing import Sequence
|
|
|
|
import allure
|
|
|
|
from test.pylib.cpp.facade import CppTestFacade, CppTestFailure
|
|
|
|
class UnitTestFacade(CppTestFacade):
|
|
|
|
def list_tests(
|
|
self,
|
|
executable: Path,
|
|
no_parallel_run: bool,
|
|
mode: str
|
|
) -> tuple[bool, list[str]]:
|
|
return False, [os.path.basename(os.path.splitext(executable)[0])]
|
|
|
|
def run_test(
|
|
self,
|
|
executable: Path,
|
|
original_name: str,
|
|
test_name: str,
|
|
mode: str,
|
|
file_name: Path,
|
|
test_args: Sequence[str] = (),
|
|
env: dict = None,
|
|
) -> tuple[list[CppTestFailure], str] | tuple[None, str]:
|
|
args = [str(executable), *test_args]
|
|
test_passed, stdout_file_path, return_code = self.run_process(test_name, mode, file_name, args, env)
|
|
|
|
if not test_passed:
|
|
allure.attach(stdout_file_path.read_bytes(), name='output', attachment_type=allure.attachment_type.TEXT)
|
|
msg = (
|
|
f'working_dir: {os.getcwd()}\n'
|
|
f'Internal Error: calling {executable} '
|
|
f'for test {test_name} failed ({return_code=}):\n'
|
|
f'output:{stdout_file_path.absolute()}\n'
|
|
f'command to repeat:{" ".join(args)}'
|
|
)
|
|
failure = CppTestFailure(
|
|
file_name.name,
|
|
line_num=0,
|
|
contents=msg
|
|
)
|
|
return [failure], ''
|
|
if not self.save_log_on_success:
|
|
stdout_file_path.unlink(missing_ok=True)
|
|
return None, ''
|