Commit 22938cb0 authored by Jan Kiene's avatar Jan Kiene
Browse files

implement keep_files arg and add printout of command

parent 3b669c89
Loading
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ from tempfile import TemporaryDirectory

HERE = Path(__file__).absolute().parent
TESTV_DIR = HERE.parent / "scripts/testv"
OUTPUT_FOLDER_IF_KEEP_FILES = HERE.joinpath("output-ambi_converter-be")

sys.path.append(str(HERE.parent / "scripts"))
from pyaudio3dtools import audiofile, audioarray
@@ -35,12 +36,12 @@ def run_ambi_converter(
        f"{int(convention_in)}",
        f"{int(convention_out)}",
    ]
    print(" ".join(cmd))

    p = subprocess.run(cmd, capture_output=True)
    if p.returncode != 0:
        pytest.fail(
            f"Ambisonics converter run failed: {p.stdout.decode('utf8') + p.stderr.decode('utf8')}"
        )
        msg = f"{p.stdout.decode('utf8')}\n{p.stderr.decode('utf8')}"
        pytest.fail(f"Ambisonics converter run failed:\n{msg}")


INPUT_FILES = [TESTV_DIR / "stv3OA48c.wav"]
@@ -57,6 +58,7 @@ def test_ambi_converter(
    infile: Path,
    convention_in: AMBI_CONVENTION,
    convention_out: AMBI_CONVENTION,
    keep_files,
    # needs to be passed to correctly report errors
    test_info,
):
@@ -66,8 +68,13 @@ def test_ambi_converter(
    ):
        pytest.xfail("One of in and out convention needs to be ACN_SN3D")

    if keep_files:
        OUTPUT_FOLDER_IF_KEEP_FILES.mkdir(exist_ok=True, parents=True)

    with TemporaryDirectory() as tmp_dir:
        outfile_base = Path(tmp_dir) / (
        output_dir = OUTPUT_FOLDER_IF_KEEP_FILES if keep_files else tmp_dir

        outfile_base = Path(output_dir) / (
            infile.stem + f"-{str(convention_in)}-to-{str(convention_out)}"
        )