| import importlib.util |
| from pathlib import Path |
|
|
|
|
| def load_task_module(): |
| path = Path(__file__).resolve().parents[1] / "scripts" / "task.py" |
| spec = importlib.util.spec_from_file_location("project_task", path) |
| assert spec is not None |
| module = importlib.util.module_from_spec(spec) |
| assert spec.loader is not None |
| spec.loader.exec_module(module) |
| return module |
|
|
|
|
| def test_task_commands_replace_make_targets() -> None: |
| task = load_task_module() |
|
|
| dev, _ = task.command_for("dev") |
| gradio, _ = task.command_for("gradio") |
| harness, _ = task.command_for("harness") |
| test, _ = task.command_for("test") |
| verify, _ = task.command_for("verify") |
| validator_smoke, _ = task.command_for("validator-smoke") |
|
|
| assert dev == ["uv", "run", "uvicorn", "app:app", "--host", "127.0.0.1", "--port", "8790"] |
| assert gradio == ["uv", "run", "python", "app.py"] |
| assert harness == ["uv", "run", "python", "-m", "arena.harness"] |
| assert test == ["uv", "run", "pytest", "tests_python"] |
| assert verify == [] |
| assert validator_smoke == ["uv", "run", "python", "-m", "arena.smoke", "validator"] |
|
|
|
|
| def test_daytona_validator_smoke_sets_provider_override() -> None: |
| task = load_task_module() |
|
|
| _, env = task.command_for("daytona-validator-smoke") |
|
|
| assert env == {"VALIDATOR_SANDBOX_PROVIDER": "daytona"} |
|
|
|
|
| def test_test_task_replaces_default_target_when_args_are_supplied() -> None: |
| task = load_task_module() |
|
|
| command, _ = task.command_for_invocation("test", ["tests_python/test_task_runner.py", "-q"]) |
|
|
| assert command == ["uv", "run", "pytest"] |
|
|
|
|
| def test_verify_runs_tests_then_agent_harness() -> None: |
| task = load_task_module() |
|
|
| commands = task._verify_commands() |
|
|
| assert commands == [ |
| (["uv", "run", "pytest", "tests_python"], {}), |
| ( |
| [ |
| "uv", |
| "run", |
| "python", |
| "-m", |
| "arena.harness", |
| "--prompt", |
| "Build a tiny CLI", |
| "--test", |
| "test -f README.md", |
| ], |
| {}, |
| ), |
| ] |
|
|
|
|
| def test_dotenv_loader_preserves_existing_env(tmp_path) -> None: |
| task = load_task_module() |
| env = {"EXISTING": "from-env"} |
| env_file = tmp_path / ".env" |
| env_file.write_text("EXISTING=from-file\nNEW_VALUE='loaded'\n# ignored\n") |
|
|
| task._load_dotenv(env_file, env) |
|
|
| assert env["EXISTING"] == "from-env" |
| assert env["NEW_VALUE"] == "loaded" |
|
|