diff --git a/tests/conftest.py b/tests/conftest.py index 91b9f786bd7bf962b0e6f4bd4e8782184f8faa62..07cd5be183e74086d996f5ac8b298cfad5d98bc5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -424,9 +424,13 @@ def dut_encoder_path(request) -> str: # fixture returns test information, enabling per-testcase SNR -@pytest.fixture +@pytest.fixture(scope="function") def test_info(request): - return request + yield request + + # Check for errors during teardown to report error instead of failure + if hasattr(request, "error"): + pytest.fail(request.error) class EncoderFrontend: diff --git a/tests/hrtf_binary_loading/utils.py b/tests/hrtf_binary_loading/utils.py index 4e74a32f7fc8301578e50878971073efbf9a2dad..0e9c5e5820e8960255f0399c5b66b3c347f8a9cb 100644 --- a/tests/hrtf_binary_loading/utils.py +++ b/tests/hrtf_binary_loading/utils.py @@ -46,6 +46,7 @@ import pyaudio3dtools def run_encoder( + test_info, bitrate: int, sampling_rate: int, input_file: str, @@ -88,10 +89,11 @@ def run_encoder( str(output_file), ] - run_cmd(cmd) + run_cmd(cmd, test_info) def run_decoder( + test_info, output_config: str, output_sampling_rate: int, input_bitstream_path: Path, @@ -125,7 +127,7 @@ def run_decoder( str(output_path), ] - run_cmd(cmd) + run_cmd(cmd, test_info) def get_option_list_str(option_list): @@ -304,7 +306,7 @@ def compare_rom_vs_binary( input_path = TESTV_DIR.joinpath(in_file).with_suffix(".wav") bitstream_path = BITSTREAM_DIR.joinpath(in_file + file_ext) run_encoder( - bitrate, in_fs, input_path, bitstream_path, add_option_list=option_list_enc + test_info, bitrate, in_fs, input_path, bitstream_path, add_option_list=option_list_enc ) if trj_file is not None: @@ -314,7 +316,7 @@ def compare_rom_vs_binary( option_list_dec = None out_rom_path = DEC_ROM_DIR.joinpath(in_file + file_ext).with_suffix(".wav") run_decoder( - out_fmt, out_fs, bitstream_path, out_rom_path, add_option_list=option_list_dec + test_info, out_fmt, out_fs, bitstream_path, out_rom_path, add_option_list=option_list_dec ) out_rom, out_rom_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) @@ -326,7 +328,7 @@ def compare_rom_vs_binary( out_bin_path = DEC_BINARY_DIR.joinpath(in_file + file_ext).with_suffix(".wav") run_decoder( - out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list_dec + test_info, out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list_dec ) out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_bin_path) diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 466b7c346a2b3f953fbc688d52eb6aa3cd18ac78..8170e1e06cc34c9a4cec7969c23427643d39dbc9 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -64,14 +64,13 @@ from ..cmp_pcm import cmp_pcm from ..conftest import parse_properties -def run_cmd(cmd, env=None): +def run_cmd(cmd, test_info, env=None): logging.info(f"\nRunning command\n{' '.join(cmd)}\n") try: sp.run(cmd, check=True, capture_output=True, text=True, env=env) except sp.CalledProcessError as e: - raise SystemError( - f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}" - ) + test_info.error = f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}" + raise SystemError(test_info.error) def run_isar_ext_rend_cmd(cmd, env=None): @@ -310,7 +309,7 @@ def run_renderer( ) # run the renderer - run_cmd(cmd, env) + run_cmd(cmd, test_info, env) if test_info.config.option.create_cut and not render_for_peaq: # CUT creation mode will run a comparison with REF @@ -350,12 +349,12 @@ def run_renderer( cmd2[0] += binary_suffix if "MASA" in str(out_fmt): cmd2.extend(["-im", out_file + ".met"]) - run_cmd(cmd2, env) + run_cmd(cmd2, test_info, env) # Render ref to BINAURAL with same settings as test cmd2[2] = str(out_file_ref) # in_file cmd2[6] = odg_ref # out_file - run_cmd(cmd2, env) + run_cmd(cmd2, test_info, env) out_fmt_bin = new_fmt else: out_fmt_bin = out_fmt @@ -368,7 +367,7 @@ def run_renderer( cmd[0] += binary_suffix cmd[6] = odg_input # out_file cmd[8] = out_fmt_bin # out_fmt - run_cmd(cmd, env) + run_cmd(cmd, test_info, env) else: odg_input = in_file diff --git a/tests/split_rendering/utils.py b/tests/split_rendering/utils.py index bb826752adef5d2d731f0cb15e17a3c38f285c22..504929b29aad8926eccf44e84aa828d2f462d9e6 100644 --- a/tests/split_rendering/utils.py +++ b/tests/split_rendering/utils.py @@ -39,7 +39,7 @@ from typing import Tuple import numpy as np import pytest -from tests.renderer.utils import check_BE, run_cmd, run_ivas_isar_enc_cmd, run_ivas_isar_dec_cmd, run_isar_post_rend_cmd, run_isar_ext_rend_cmd +from tests.renderer.utils import check_BE, run_ivas_isar_enc_cmd, run_ivas_isar_dec_cmd, run_isar_post_rend_cmd, run_isar_ext_rend_cmd from tests.split_rendering.constants import * sys.path.append(SCRIPTS_DIR)