Files
wehub-resource-sync bcbd1bdb22
Test (Python) / test-python-gate (push) Blocked by required conditions
Test (TypeScript) / test-typescript-gate (push) Blocked by required conditions
CLI exit codes / cli-gate (push) Blocked by required conditions
Test (Install) / test-install-gate (push) Blocked by required conditions
Integ / integ-gate (push) Blocked by required conditions
CLI exit codes / Python CLI (push) Waiting to run
Integ / changes (push) Has been skipped
Test (Install) / python-minimal (3.11) (push) Waiting to run
Test (Install) / python-minimal (3.12) (push) Waiting to run
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Waiting to run
Integ / integ-ts (push) Waiting to run
Integ / integ (push) Waiting to run
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Waiting to run
Integ / integ-database (push) Waiting to run
Test (Install) / python-extra (email, mirage.resource.email) (push) Waiting to run
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Waiting to run
Integ / integ-ssh (push) Waiting to run
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
CLI exit codes / TypeScript CLI (push) Waiting to run
CLI exit codes / Cross-language snapshot interop (push) Waiting to run
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Waiting to run
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Waiting to run
Test (Python) / changes (push) Has been skipped
Integ / integ-database-ts (push) Waiting to run
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Waiting to run
Integ / integ-data (push) Waiting to run
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Waiting to run
Test (Python) / test (push) Waiting to run
Integ / integ-fuse (push) Waiting to run
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Waiting to run
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Waiting to run
Test (Python) / audit (push) Waiting to run
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Waiting to run
Integ / integ-ssh-ts (push) Waiting to run
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Waiting to run
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Waiting to run
Test (TypeScript) / changes (push) Has been skipped
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Waiting to run
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Waiting to run
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Waiting to run
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Waiting to run
Test (TypeScript) / test (push) Waiting to run
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Waiting to run
Test (TypeScript) / python-fs-shim (push) Waiting to run
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Waiting to run
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Waiting to run
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Waiting to run
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Waiting to run
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Waiting to run
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Waiting to run
Test (Install) / ts-minimal (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:30:44 +08:00

100 lines
3.0 KiB
Python

import asyncio
import pytest
from mirage.io import IOResult
from mirage.io.stream import materialize
from mirage.workspace.executor.builtins.timeout import (handle_timeout,
parse_duration)
from mirage.workspace.session.session import Session
class FakeShell:
def __init__(self, delay: float = 0.0, exit_code: int = 0):
self.lines: list[str] = []
self.delay = delay
self.exit_code = exit_code
async def __call__(self, line: str, session_id: str) -> IOResult:
self.lines.append(line)
if self.delay:
await asyncio.sleep(self.delay)
return IOResult(stdout=b"done\n", exit_code=self.exit_code)
def make_session() -> Session:
return Session(session_id="s1")
def test_parse_duration_units():
assert parse_duration("1") == 1.0
assert parse_duration("0.5") == 0.5
assert parse_duration("2s") == 2.0
assert parse_duration("2m") == 120.0
assert parse_duration("1h") == 3600.0
assert parse_duration("1d") == 86400.0
assert parse_duration(".5") == 0.5
def test_parse_duration_rejects_garbage():
assert parse_duration("xx") is None
assert parse_duration("-1") is None
assert parse_duration("1x") is None
assert parse_duration("") is None
@pytest.mark.asyncio
async def test_command_finishing_in_time_passes_through():
shell = FakeShell(exit_code=3)
stdout, io, _ = await handle_timeout(shell, ["5", "wc", "-l"],
make_session())
assert shell.lines == ["wc -l"]
assert io.exit_code == 3
assert stdout == b"done\n"
@pytest.mark.asyncio
async def test_overrun_exits_124():
shell = FakeShell(delay=1.0)
_, io, node = await handle_timeout(shell, ["0.05", "sleep", "1"],
make_session())
assert io.exit_code == 124
assert node.exit_code == 124
@pytest.mark.asyncio
async def test_invalid_duration_exits_125():
shell = FakeShell()
_, io, _ = await handle_timeout(shell, ["xx", "sleep", "1"],
make_session())
assert io.exit_code == 125
assert (await
materialize(io.stderr)) == b"timeout: invalid time interval 'xx'\n"
assert shell.lines == []
@pytest.mark.asyncio
async def test_missing_operand_exits_125():
shell = FakeShell()
_, io, _ = await handle_timeout(shell, ["5"], make_session())
assert io.exit_code == 125
assert await materialize(io.stderr) == b"timeout: missing operand\n"
@pytest.mark.asyncio
async def test_signal_option_rejected():
shell = FakeShell()
_, io, _ = await handle_timeout(shell, ["-s", "KILL", "1", "sleep", "3"],
make_session())
assert io.exit_code == 125
assert (await
materialize(io.stderr)) == b"timeout: unsupported option -- '-s'\n"
@pytest.mark.asyncio
async def test_quoting_survives_rejoin():
shell = FakeShell()
await handle_timeout(shell, ["1", "grep", "a b", "f.txt"], make_session())
assert shell.lines == ["grep 'a b' f.txt"]