feat: smooth browser challenge harness runs
This commit is contained in:
@@ -592,6 +592,63 @@ def test_prepare_trial_workspace_uses_next_available_directory(
|
||||
assert stale.read_text(encoding="utf-8") == "stale"
|
||||
|
||||
|
||||
def test_main_uses_custom_workspace_template_and_source_root(
|
||||
tmp_path: Path,
|
||||
monkeypatch,
|
||||
capsys,
|
||||
) -> None:
|
||||
template = tmp_path / "template"
|
||||
template.mkdir()
|
||||
(template / "prompt.md").write_text("custom prompt", encoding="utf-8")
|
||||
source_root = tmp_path / "source"
|
||||
source_root.mkdir()
|
||||
workspaces = tmp_path / "workspaces"
|
||||
results = tmp_path / "results"
|
||||
|
||||
def fake_run_trial(
|
||||
config: TrialConfig,
|
||||
*,
|
||||
index: int,
|
||||
results_dir: Path,
|
||||
) -> dict[str, object]:
|
||||
return {
|
||||
"index": index,
|
||||
"classification": "success",
|
||||
"returncode": 0,
|
||||
"duration_seconds": 1.0,
|
||||
"report_path": config.prompt_path.parent / "final-report.md",
|
||||
}
|
||||
|
||||
monkeypatch.setattr(run_opencode_trials, "run_trial", fake_run_trial)
|
||||
|
||||
assert (
|
||||
run_opencode_trials.main(
|
||||
[
|
||||
"--model",
|
||||
"check/model",
|
||||
"--trials",
|
||||
"1",
|
||||
"--workspace-template",
|
||||
str(template),
|
||||
"--source-root",
|
||||
str(source_root),
|
||||
"--workspaces-dir",
|
||||
str(workspaces),
|
||||
"--results-dir",
|
||||
str(results),
|
||||
]
|
||||
)
|
||||
== 0
|
||||
)
|
||||
|
||||
workspace = workspaces / "check_model-trial-001"
|
||||
assert workspace.exists()
|
||||
assert (workspace / "prompt.md").read_text(encoding="utf-8") == "custom prompt"
|
||||
config = json.loads((workspace / "wf.config.json").read_text(encoding="utf-8"))
|
||||
assert config["server"]["sources"][0]["path"] == "../../source"
|
||||
assert '"success_count": 1' in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_starting_trial_index_accounts_for_existing_results_and_workspaces(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
||||
@@ -144,6 +144,37 @@ registry = [echo]
|
||||
]
|
||||
|
||||
|
||||
def test_wf_config_validate_uses_global_config_when_path_omitted(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
config_path = tmp_path / "wf.config.json"
|
||||
config_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"version": 1,
|
||||
"server": {
|
||||
"store": {"kind": "filesystem", "root": "store"},
|
||||
"sources": [{"kind": "stdlib", "id": "wf.std"}],
|
||||
},
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
result = CliRunner().invoke(
|
||||
app,
|
||||
["--config", str(config_path), "config", "validate"],
|
||||
)
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
payload = json.loads(result.output)
|
||||
assert payload["valid"] is True
|
||||
assert payload["path"] == str(config_path)
|
||||
assert payload["sources"] == [
|
||||
{"id": "wf.std", "kind": "stdlib", "status": "ok"}
|
||||
]
|
||||
|
||||
|
||||
def test_wf_config_validate_reports_python_source_import_failure(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "wf.config.json"
|
||||
config_path.write_text(
|
||||
|
||||
Reference in New Issue
Block a user