from pathlib import Path

import pytest

pytestmark = pytest.mark.pytest

from byteb4rb1e.testing.pytest.decorators import run_in_subprocess_once


@run_in_subprocess_once()
def test_run_in_subprocess_once(tmp_path):
    marker = tmp_path / "executed_in_subprocess.txt"

    if marker.exists():
        raise AssertionError("Marker file exists before test logic ran (shouldn't happen in parent process)")

    # Create proof of execution
    marker.write_text("Subprocess was here.")

    # Now assert it
    assert marker.exists()
