596 lines
24 KiB
Python
596 lines
24 KiB
Python
"""Real installed-module processes; raw framing here is test-client code only."""
|
|
|
|
import asyncio
|
|
import json
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import uuid
|
|
from collections.abc import AsyncIterator, Iterator
|
|
from datetime import timedelta
|
|
from importlib.metadata import distribution
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
import anyio
|
|
import mido # type: ignore[import-untyped]
|
|
import pytest
|
|
from jsonschema import Draft202012Validator
|
|
from mcp import ClientSession, types
|
|
from mcp.client.stdio import StdioServerParameters, stdio_client
|
|
from mcp.shared.version import SUPPORTED_PROTOCOL_VERSIONS
|
|
from pydantic import JsonValue
|
|
|
|
from riff_groove_builder import __version__
|
|
from riff_groove_builder.schemas import (
|
|
GenerationError,
|
|
GenerationResult,
|
|
ProfileListResult,
|
|
ToolName,
|
|
tool_input_schema,
|
|
tool_output_schema,
|
|
)
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
pytestmark = pytest.mark.anyio
|
|
TIMEOUT = 15
|
|
|
|
|
|
@pytest.fixture
|
|
def anyio_backend() -> str:
|
|
return "asyncio"
|
|
|
|
|
|
@pytest.fixture
|
|
def workspace() -> Iterator[Path]:
|
|
path = ROOT / ".test-artifacts" / f"stdio-{uuid.uuid4().hex}"
|
|
path.mkdir(parents=True)
|
|
(path / "outputs").mkdir()
|
|
(path / "other-cwd").mkdir()
|
|
try:
|
|
yield path
|
|
finally:
|
|
shutil.rmtree(path)
|
|
|
|
|
|
def _environment() -> dict[str, str]:
|
|
env = os.environ.copy()
|
|
for key in ("PYTHONPATH", "PYTHONHOME"):
|
|
env.pop(key, None)
|
|
env["PYTHONDONTWRITEBYTECODE"] = "1"
|
|
return env
|
|
|
|
|
|
async def test_official_client_handshake_and_both_tools(workspace: Path) -> None:
|
|
direct_url = distribution("gaj3t-musicgen-riff-groove-builder").read_text("direct_url.json")
|
|
assert direct_url is not None and json.loads(direct_url)["dir_info"]["editable"] is True
|
|
parameters = StdioServerParameters(
|
|
command=sys.executable,
|
|
args=["-I", "-B", "-m", "riff_groove_builder", "--output-dir", str(workspace / "outputs")],
|
|
cwd=workspace / "other-cwd",
|
|
env=_environment(),
|
|
)
|
|
with (workspace / "client-stderr.log").open("w+", encoding="utf-8") as diagnostics:
|
|
with anyio.fail_after(45):
|
|
async with stdio_client(parameters, errlog=diagnostics) as (read, write):
|
|
async with ClientSession(
|
|
read, write, read_timeout_seconds=timedelta(seconds=TIMEOUT)
|
|
) as session:
|
|
initialized = await session.initialize()
|
|
assert initialized.protocolVersion in SUPPORTED_PROTOCOL_VERSIONS
|
|
assert initialized.serverInfo.name == "riff-groove-builder"
|
|
assert initialized.serverInfo.version == __version__
|
|
assert initialized.capabilities.tools is not None
|
|
assert initialized.capabilities.resources is None
|
|
assert initialized.capabilities.prompts is None
|
|
assert initialized.capabilities.logging is None
|
|
listed = await session.list_tools()
|
|
assert [tool.name for tool in listed.tools] == [
|
|
"list_instrument_profiles",
|
|
"generate_music",
|
|
]
|
|
names: tuple[ToolName, ...] = ("list_instrument_profiles", "generate_music")
|
|
for name, tool in zip(names, listed.tools, strict=True):
|
|
assert tool.inputSchema == tool_input_schema(name)
|
|
assert tool.outputSchema == tool_output_schema(name)
|
|
arguments = (
|
|
{}
|
|
if name == "list_instrument_profiles"
|
|
else {
|
|
"description": "lead bass drums 137.5 BPM 2 bars 7/8 quarter",
|
|
"basename": "example",
|
|
}
|
|
)
|
|
result = await session.call_tool(name, arguments)
|
|
assert result.content and isinstance(result.content[0], types.TextContent)
|
|
assert json.loads(result.content[0].text) == result.structuredContent
|
|
Draft202012Validator(tool.outputSchema).validate(result.structuredContent)
|
|
if name == "list_instrument_profiles":
|
|
assert not result.isError
|
|
profiles = ProfileListResult.model_validate(result.structuredContent)
|
|
assert len(profiles.profiles) == 6
|
|
assert [p.native_available for p in profiles.profiles] == [
|
|
True,
|
|
True,
|
|
False,
|
|
False,
|
|
False,
|
|
False,
|
|
]
|
|
else:
|
|
assert not result.isError
|
|
generated = GenerationResult.model_validate(result.structuredContent)
|
|
assert generated.status == "midi_fallback"
|
|
assert generated.resolved.tempo_bpm == 137.5
|
|
assert generated.resolved.musical_end_tick == 6720
|
|
artifact = generated.artifacts[0]
|
|
assert artifact.fallback_for == ["drums"]
|
|
assert [a.format for a in generated.artifacts] == [
|
|
"mid",
|
|
"griff",
|
|
"briff",
|
|
]
|
|
path = Path(artifact.path)
|
|
assert path.parent == workspace / "outputs" / "example"
|
|
assert path.stat().st_size == artifact.size_bytes
|
|
assert path.read_bytes().startswith(b"MThd")
|
|
midi = mido.MidiFile(path)
|
|
assert midi.type == 1 and midi.ticks_per_beat == 960
|
|
assert [track.name for track in midi.tracks] == [
|
|
"Conductor",
|
|
"Lead",
|
|
"Bass",
|
|
"Drums",
|
|
]
|
|
assert [sum(msg.time for msg in track) for track in midi.tracks] == [
|
|
6720
|
|
] * 4
|
|
diagnostics.seek(0)
|
|
assert diagnostics.read() == ""
|
|
assert list((workspace / "outputs").iterdir()) == [workspace / "outputs" / "example"]
|
|
|
|
|
|
class RawStdio:
|
|
def __init__(self, process: asyncio.subprocess.Process) -> None:
|
|
self.process = process
|
|
self.lines: list[bytes] = []
|
|
self.diagnostics = b""
|
|
assert process.stderr is not None
|
|
self._stderr = asyncio.create_task(process.stderr.read())
|
|
|
|
async def send(self, message: dict[str, Any] | str) -> None:
|
|
assert self.process.stdin is not None
|
|
text = message if isinstance(message, str) else json.dumps(message, ensure_ascii=False)
|
|
self.process.stdin.write((text + "\n").encode("utf-8"))
|
|
await asyncio.wait_for(self.process.stdin.drain(), TIMEOUT)
|
|
|
|
async def receive(self, timeout: float = TIMEOUT) -> dict[str, Any]:
|
|
assert self.process.stdout is not None
|
|
line = await asyncio.wait_for(self.process.stdout.readline(), timeout)
|
|
assert line, "Unexpected EOF from server"
|
|
self.lines.append(line)
|
|
assert line.endswith(b"\n")
|
|
types.JSONRPCMessage.model_validate_json(line)
|
|
result = json.loads(line.decode("utf-8"))
|
|
assert isinstance(result, dict)
|
|
return result
|
|
|
|
async def request(
|
|
self, identifier: str | int, method: str, params: dict[str, Any] | None = None
|
|
) -> dict[str, Any]:
|
|
message: dict[str, Any] = {"jsonrpc": "2.0", "id": identifier, "method": method}
|
|
if params is not None:
|
|
message["params"] = params
|
|
await self.send(message)
|
|
response = await self.receive()
|
|
assert response["id"] == identifier
|
|
return response
|
|
|
|
async def initialize(self, version: str = "2025-11-25") -> dict[str, Any]:
|
|
response = await self.request(
|
|
"initialize-string-id",
|
|
"initialize",
|
|
{
|
|
"protocolVersion": version,
|
|
"capabilities": {},
|
|
"clientInfo": {"name": "raw-test-client", "version": "0"},
|
|
},
|
|
)
|
|
await self.send({"jsonrpc": "2.0", "method": "notifications/initialized"})
|
|
assert response["result"]["serverInfo"]["version"] == __version__
|
|
return response
|
|
|
|
async def assert_quiet(self) -> None:
|
|
with pytest.raises(TimeoutError):
|
|
await self.receive(timeout=0.2)
|
|
|
|
async def close(self) -> None:
|
|
if self.process.returncode is None:
|
|
assert self.process.stdin is not None
|
|
self.process.stdin.close()
|
|
try:
|
|
await asyncio.wait_for(self.process.wait(), TIMEOUT)
|
|
except BaseException:
|
|
if self.process.returncode is None:
|
|
self.process.kill()
|
|
await asyncio.wait_for(self.process.wait(), TIMEOUT)
|
|
raise
|
|
assert self.process.stdout is not None
|
|
remainder = await asyncio.wait_for(self.process.stdout.read(), TIMEOUT)
|
|
self.lines.extend(remainder.splitlines(keepends=True))
|
|
self.diagnostics = await asyncio.wait_for(self._stderr, TIMEOUT)
|
|
for line in self.lines:
|
|
assert line.endswith(b"\n")
|
|
types.JSONRPCMessage.model_validate_json(line)
|
|
json.loads(line.decode("utf-8"))
|
|
assert self.process.returncode == 0, self.diagnostics.decode("utf-8")
|
|
|
|
|
|
@pytest.fixture
|
|
async def raw(workspace: Path) -> AsyncIterator[RawStdio]:
|
|
process = await asyncio.wait_for(
|
|
asyncio.create_subprocess_exec(
|
|
sys.executable,
|
|
"-I",
|
|
"-B",
|
|
"-m",
|
|
"riff_groove_builder",
|
|
"--output-dir",
|
|
str(workspace / "outputs"),
|
|
cwd=workspace / "other-cwd",
|
|
env=_environment(),
|
|
stdin=asyncio.subprocess.PIPE,
|
|
stdout=asyncio.subprocess.PIPE,
|
|
stderr=asyncio.subprocess.PIPE,
|
|
),
|
|
TIMEOUT,
|
|
)
|
|
client = RawStdio(process)
|
|
try:
|
|
yield client
|
|
finally:
|
|
await client.close()
|
|
assert not list((workspace / "outputs").glob(".riff-stage-*"))
|
|
for published in (workspace / "outputs").iterdir():
|
|
assert published.name in ("one", "midi", "native")
|
|
assert list(published.iterdir()) == [published / f"{published.name}.mid"]
|
|
assert mido.MidiFile(published / f"{published.name}.mid").type == 1
|
|
|
|
|
|
async def test_raw_ids_notifications_outputs_and_eof(raw: RawStdio) -> None:
|
|
initialized = await raw.initialize()
|
|
assert initialized["result"]["protocolVersion"] in SUPPORTED_PROTOCOL_VERSIONS
|
|
await raw.assert_quiet()
|
|
listed = await raw.request(73, "tools/list")
|
|
tools = listed["result"]["tools"]
|
|
assert [tool["name"] for tool in tools] == ["list_instrument_profiles", "generate_music"]
|
|
for tool in tools:
|
|
name = tool["name"]
|
|
assert name in ("list_instrument_profiles", "generate_music")
|
|
assert tool["inputSchema"] == tool_input_schema(name)
|
|
assert tool["outputSchema"] == tool_output_schema(name)
|
|
for index, arguments in enumerate(
|
|
[
|
|
{
|
|
"description": "lead only 1 bar quarter",
|
|
"basename": "one",
|
|
"profiles": {"lead": "standard.lead.v1"},
|
|
},
|
|
{
|
|
"description": "drums only 1 bar quarter",
|
|
"basename": "two",
|
|
"parts": ["drums"],
|
|
"formats": ["sdp"],
|
|
"allow_midi_fallback": False,
|
|
"time_signature": {"numerator": 7, "denominator": 8},
|
|
"key": "Bb major",
|
|
},
|
|
]
|
|
):
|
|
response = await raw.request(
|
|
f"generation-{index}", "tools/call", {"name": "generate_music", "arguments": arguments}
|
|
)
|
|
result = response["result"]
|
|
if index == 0:
|
|
assert result["isError"] is False
|
|
generated = GenerationResult.model_validate(result["structuredContent"])
|
|
assert generated.status == "midi_fallback"
|
|
assert Path(generated.artifacts[0].path).read_bytes().startswith(b"MThd")
|
|
else:
|
|
assert result["isError"] is True
|
|
error = GenerationError.model_validate(result["structuredContent"])
|
|
assert error.code == "NATIVE_FORMAT_UNAVAILABLE"
|
|
assert error.details == {
|
|
"format": "sd3p",
|
|
"part": "drums",
|
|
"reason": "sdp_template_required",
|
|
}
|
|
Draft202012Validator(tool_output_schema("generate_music")).validate(
|
|
result["structuredContent"]
|
|
)
|
|
profiles = await raw.request(
|
|
74, "tools/call", {"name": "list_instrument_profiles", "arguments": {}}
|
|
)
|
|
assert profiles["result"]["isError"] is False
|
|
summaries = ProfileListResult.model_validate(profiles["result"]["structuredContent"]).profiles
|
|
assert len(summaries) == 6
|
|
Draft202012Validator(tool_output_schema("list_instrument_profiles")).validate(
|
|
profiles["result"]["structuredContent"]
|
|
)
|
|
await raw.send(
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"method": "notifications/progress",
|
|
"params": {
|
|
"progressToken": "unused",
|
|
"progress": 1,
|
|
},
|
|
}
|
|
)
|
|
assert (await raw.request("ping-barrier", "ping"))["result"] == {}
|
|
await raw.assert_quiet()
|
|
await raw.close()
|
|
assert raw.diagnostics == b""
|
|
|
|
|
|
@pytest.mark.parametrize("version", ["2024-11-05", "unsupported-client-version"])
|
|
async def test_sdk_negotiation(raw: RawStdio, version: str) -> None:
|
|
response = await raw.initialize(version)
|
|
negotiated = response["result"]["protocolVersion"]
|
|
assert negotiated in SUPPORTED_PROTOCOL_VERSIONS
|
|
if version in SUPPORTED_PROTOCOL_VERSIONS:
|
|
assert negotiated == version
|
|
await raw.assert_quiet()
|
|
|
|
|
|
async def test_real_stdio_midi_native_only_collision_and_resolved_errors(raw: RawStdio) -> None:
|
|
await raw.initialize()
|
|
for basename, formats, status, fallback in [
|
|
("midi", ["mid"], "complete", []),
|
|
("native", ["agp", "sdp"], "midi_fallback", ["lead", "bass", "drums"]),
|
|
]:
|
|
response = await raw.request(
|
|
basename,
|
|
"tools/call",
|
|
{
|
|
"name": "generate_music",
|
|
"arguments": {
|
|
"description": "lead bass drums 1 bar quarter",
|
|
"basename": basename,
|
|
"formats": formats,
|
|
"profiles": {
|
|
"lead": "standard.lead.v1",
|
|
"bass": "standard.bass.v1",
|
|
"drums": "standard.gm-drums.v1",
|
|
},
|
|
},
|
|
},
|
|
)
|
|
result = response["result"]
|
|
assert not result["isError"]
|
|
generated = GenerationResult.model_validate(result["structuredContent"])
|
|
assert generated.status == status
|
|
artifact = generated.artifacts[0]
|
|
assert artifact.fallback_for == fallback
|
|
assert Path(artifact.path).stat().st_size == artifact.size_bytes
|
|
assert Path(artifact.path).read_bytes().startswith(b"MThd")
|
|
assert [
|
|
warning.part
|
|
for warning in generated.warnings
|
|
if warning.code == "STANDARD_MIDI_MAPPING"
|
|
] == ["lead", "bass", "drums"]
|
|
Draft202012Validator(tool_output_schema("generate_music")).validate(
|
|
result["structuredContent"]
|
|
)
|
|
cases: list[tuple[dict[str, JsonValue], str]] = [
|
|
({"description": "drums only", "basename": "x", "formats": ["agp"]}, "INVALID_REQUEST"),
|
|
(
|
|
{
|
|
"description": "lead only palm mute",
|
|
"basename": "x",
|
|
"profiles": {"lead": "standard.lead.v1"},
|
|
},
|
|
"UNSUPPORTED_ARTICULATION",
|
|
),
|
|
({"description": "lead only", "basename": "midi"}, "OUTPUT_EXISTS"),
|
|
({"description": "private-description", "basename": "x"}, "UNSUPPORTED_DESCRIPTION"),
|
|
]
|
|
for index, (arguments, code) in enumerate(cases):
|
|
response = await raw.request(
|
|
f"error-{index}", "tools/call", {"name": "generate_music", "arguments": arguments}
|
|
)
|
|
result = response["result"]
|
|
assert result["isError"]
|
|
assert result["structuredContent"]["code"] == code
|
|
assert "private-" not in json.dumps(result)
|
|
Draft202012Validator(tool_output_schema("generate_music")).validate(
|
|
result["structuredContent"]
|
|
)
|
|
await raw.close()
|
|
assert raw.diagnostics == b""
|
|
|
|
|
|
async def test_invalid_arguments_and_unknown_tools(raw: RawStdio) -> None:
|
|
await raw.initialize()
|
|
cases: list[tuple[ToolName, dict[str, JsonValue]]] = [
|
|
("list_instrument_profiles", {"private-property": "secret"}),
|
|
("generate_music", {}),
|
|
("generate_music", {"description": "private-description", "basename": "x", "bars": 4.0}),
|
|
(
|
|
"generate_music",
|
|
{
|
|
"description": "private-description",
|
|
"basename": "x",
|
|
"parts": ["lead"],
|
|
"formats": ["sdp"],
|
|
},
|
|
),
|
|
]
|
|
for index, (name, arguments) in enumerate(cases):
|
|
response = await raw.request(index, "tools/call", {"name": name, "arguments": arguments})
|
|
result = response["result"]
|
|
assert result["isError"] is True
|
|
assert result["structuredContent"]["code"] == "INVALID_REQUEST"
|
|
assert result["structuredContent"]["details"]["issues"]
|
|
assert "private-" not in json.dumps(response)
|
|
assert "secret" not in json.dumps(response)
|
|
Draft202012Validator(tool_output_schema(name)).validate(result["structuredContent"])
|
|
unknown = await raw.request(
|
|
"unknown-tool", "tools/call", {"name": "private-unknown-tool", "arguments": {}}
|
|
)
|
|
assert unknown["result"]["isError"] is True
|
|
assert "Unknown tool." in unknown["result"]["content"][0]["text"]
|
|
assert "structuredContent" not in unknown["result"]
|
|
await raw.close()
|
|
assert b"private-" not in raw.diagnostics
|
|
assert b"secret" not in raw.diagnostics
|
|
|
|
|
|
async def test_sdk_unknown_methods_and_invalid_request_parameters(raw: RawStdio) -> None:
|
|
await raw.initialize()
|
|
# Unknown union methods fail SDK request validation; recognized but unregistered
|
|
# methods reach SDK dispatch and receive METHOD_NOT_FOUND.
|
|
cases: list[tuple[str | int, str, dict[str, Any], int]] = [
|
|
("unknown-method", "private-unknown-method", {}, types.INVALID_PARAMS),
|
|
(202, "tools/call", {"arguments": {"private-property": "secret"}}, types.INVALID_PARAMS),
|
|
(
|
|
"wrong-args-type",
|
|
"tools/call",
|
|
{"name": "generate_music", "arguments": "secret"},
|
|
types.INVALID_PARAMS,
|
|
),
|
|
("unregistered", "resources/list", {}, types.METHOD_NOT_FOUND),
|
|
]
|
|
for identifier, method, params, code in cases:
|
|
response = await raw.request(identifier, method, params)
|
|
assert response["error"]["code"] == code
|
|
assert "private-" not in json.dumps(response)
|
|
assert "secret" not in json.dumps(response)
|
|
await raw.send(
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"method": "private-unknown-notification",
|
|
"params": {"private-property": "secret"},
|
|
}
|
|
)
|
|
await raw.assert_quiet()
|
|
assert (await raw.request("still-alive", "ping"))["result"] == {}
|
|
await raw.close()
|
|
assert b"SDK rejected invalid protocol parameters." in raw.diagnostics
|
|
assert b"private-" not in raw.diagnostics and b"secret" not in raw.diagnostics
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"malformed",
|
|
[
|
|
'{"private-description": "secret", invalid JSON',
|
|
'["private-description", "secret"]',
|
|
'{"jsonrpc":"2.0","id":7,"params":{"private-value":"secret"}}',
|
|
],
|
|
)
|
|
async def test_sdk_malformed_input_logs_notification_then_recovers(
|
|
raw: RawStdio, malformed: str
|
|
) -> None:
|
|
await raw.initialize()
|
|
await raw.send(malformed)
|
|
notification = await raw.receive()
|
|
assert notification["method"] == "notifications/message"
|
|
assert "id" not in notification
|
|
assert notification["params"]["data"] == "Internal Server Error"
|
|
assert "private-" not in json.dumps(notification)
|
|
assert "secret" not in json.dumps(notification)
|
|
assert (await raw.request("after-malformed", "ping"))["result"] == {}
|
|
await raw.close()
|
|
assert b"SDK rejected malformed protocol input" in raw.diagnostics
|
|
assert b"private-" not in raw.diagnostics and b"secret" not in raw.diagnostics
|
|
|
|
|
|
async def test_sdk_null_id_is_classified_as_notification(raw: RawStdio) -> None:
|
|
await raw.initialize()
|
|
await raw.send(
|
|
{"jsonrpc": "2.0", "id": None, "method": "private-method", "params": {"value": "secret"}}
|
|
)
|
|
await raw.assert_quiet()
|
|
assert (await raw.request("after-null-id", "ping"))["result"] == {}
|
|
await raw.close()
|
|
assert b"SDK rejected invalid protocol parameters." in raw.diagnostics
|
|
assert b"private-" not in raw.diagnostics and b"secret" not in raw.diagnostics
|
|
|
|
|
|
async def test_eof_without_initialization_is_clean(raw: RawStdio) -> None:
|
|
await raw.close()
|
|
assert raw.lines == []
|
|
assert raw.diagnostics == b""
|
|
|
|
|
|
@pytest.mark.parametrize("kind", ["missing", "nonexistent", "file", "uri", "unc", "device"])
|
|
def test_bad_startup_has_no_protocol_stdout(workspace: Path, kind: str) -> None:
|
|
arguments = [sys.executable, "-I", "-B", "-m", "riff_groove_builder"]
|
|
sentinel = workspace / "sentinel"
|
|
sentinel.write_text("preserved", encoding="utf-8")
|
|
roots = {
|
|
"nonexistent": str(workspace / "does-not-exist"),
|
|
"file": str(sentinel),
|
|
"uri": "https://example.invalid/music",
|
|
"unc": r"\\server\share",
|
|
"device": r"\\.\NUL",
|
|
}
|
|
if kind != "missing":
|
|
arguments.extend(["--output-dir", roots[kind]])
|
|
result = subprocess.run(
|
|
arguments,
|
|
cwd=workspace / "other-cwd",
|
|
env=_environment(),
|
|
input=b"",
|
|
capture_output=True,
|
|
timeout=TIMEOUT,
|
|
check=False,
|
|
)
|
|
assert result.returncode != 0
|
|
assert result.stdout == b""
|
|
assert result.stderr
|
|
assert (
|
|
b"--output-dir" in result.stderr
|
|
if kind == "missing"
|
|
else b"local directory" in result.stderr
|
|
)
|
|
assert sentinel.read_text(encoding="utf-8") == "preserved"
|
|
assert not (workspace / "does-not-exist").exists()
|
|
assert not list((workspace / "outputs").iterdir())
|
|
|
|
|
|
@pytest.mark.parametrize("kind", ["missing", "corrupt", "unsupported"])
|
|
def test_bad_explicit_sd3_template_startup_is_visible_and_private(
|
|
workspace: Path, kind: str
|
|
) -> None:
|
|
template = workspace / "operator.sd3p"
|
|
if kind == "corrupt":
|
|
template.write_bytes(b"private-project-bytes {")
|
|
elif kind == "unsupported":
|
|
raw = (ROOT / "tests" / "fixtures" / "sd3" / "original-template.sd3p").read_bytes()
|
|
template.write_bytes(raw.replace(b"3.4.4", b"3.4.5"))
|
|
result = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"-I",
|
|
"-B",
|
|
"-m",
|
|
"riff_groove_builder",
|
|
"--output-dir",
|
|
str(workspace / "outputs"),
|
|
"--sd3-template",
|
|
str(template),
|
|
],
|
|
cwd=workspace / "other-cwd",
|
|
env=_environment(),
|
|
input=b"",
|
|
capture_output=True,
|
|
timeout=TIMEOUT,
|
|
check=False,
|
|
)
|
|
assert result.returncode != 0 and result.stdout == b""
|
|
assert (b"OUTPUT_IO_ERROR" if kind == "missing" else b"SERIALIZATION_ERROR") in result.stderr
|
|
assert b"private-project-bytes" not in result.stderr and b"Traceback" not in result.stderr
|
|
assert not list((workspace / "outputs").iterdir())
|