default profile falls back to built-in defaults
This commit is contained in:
1 parent
b2d72f2dc9
commit
193c6cd9eb
3 files changed
+21
-2
No files matched your search
@@ -19,6 +19,9 @@ done, failed, needs-human (gate still red, or the agent wanted something the all
|
|||||||
|
|
||||||
## Profile (`~/.config/orch/profiles/NAME.toml`)
|
## Profile (`~/.config/orch/profiles/NAME.toml`)
|
||||||
|
|
||||||
|
`--profile` defaults to `default`; if `default.toml` does not exist, built-in defaults apply (`hx` from PATH, your own
|
||||||
|
`~/.hx` login, 2 retries, no allowlist). Any other missing profile name is an error.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
hx = "hx" # command
|
hx = "hx" # command
|
||||||
home = "/work/hxhome" # own HOME => own hx login
|
home = "/work/hxhome" # own HOME => own hx login
|
||||||
|
|||||||
+7
-2
@@ -94,8 +94,13 @@ impl Profile {
|
|||||||
let path = crate::config_dir()
|
let path = crate::config_dir()
|
||||||
.join("profiles")
|
.join("profiles")
|
||||||
.join(format!("{name}.toml"));
|
.join(format!("{name}.toml"));
|
||||||
let s = std::fs::read_to_string(&path)
|
let s = match std::fs::read_to_string(&path) {
|
||||||
.with_context(|| format!("profile {}", path.display()))?;
|
// only the implicit profile may be missing; a typo in any other name must still fail
|
||||||
|
Err(e) if name == "default" && e.kind() == std::io::ErrorKind::NotFound => {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
r => r.with_context(|| format!("profile {}", path.display()))?,
|
||||||
|
};
|
||||||
Self::parse(&s).with_context(|| path.display().to_string())
|
Self::parse(&s).with_context(|| path.display().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,6 +316,17 @@ shutil.copytree(ev, broken)
|
|||||||
bad = subprocess.run([orch, "bench", str(broken), "--check"], env=env, capture_output=True, text=True)
|
bad = subprocess.run([orch, "bench", str(broken), "--check"], env=env, capture_output=True, text=True)
|
||||||
assert bad.returncode == 1 and "broken case" in bad.stdout, bad
|
assert bad.returncode == 1 and "broken case" in bad.stdout, bad
|
||||||
|
|
||||||
|
# --- no profile file: `default` falls back to built-in defaults, other names still fail ---
|
||||||
|
nocfg = {**env, "ORCH_CONFIG_DIR": str(tmp / "no-cfg"), "FAKE_VERSION": "0"}
|
||||||
|
(tmp / "bin").mkdir(exist_ok=True)
|
||||||
|
hxw = tmp / "bin/hx"
|
||||||
|
hxw.write_text(f"#!/bin/sh\nexec {sys.executable} {fake} \"$@\"\n")
|
||||||
|
hxw.chmod(0o755)
|
||||||
|
nb = subprocess.run([orch, "bench", str(ev), "--case", "fix-typo-readme", "--out", str(tmp / "nb.jsonl")], env={**nocfg, "PATH": f"{tmp / 'bin'}:{os.environ['PATH']}", "SOLVE_DIR": str(ev)}, capture_output=True, text=True)
|
||||||
|
assert nb.returncode == 1 and (tmp / "nb.jsonl").exists() and "default.toml" not in nb.stderr, nb # hx ran (unsolved: SOLVE_DIR is filtered from its env), no missing-profile error
|
||||||
|
miss = subprocess.run([orch, "bench", str(ev), "--profile", "typo"], env=nocfg, capture_output=True, text=True)
|
||||||
|
assert miss.returncode != 0 and "typo.toml" in miss.stderr, miss
|
||||||
|
|
||||||
# kill orch mid-run: status must say interrupted and hx must be dead after the next orch call
|
# kill orch mid-run: status must say interrupted and hx must be dead after the next orch call
|
||||||
pidfile = tmp / "hx.pid"
|
pidfile = tmp / "hx.pid"
|
||||||
p = subprocess.Popen([orch, "run", str(task("killed", "HANG")), "--repo", str(repo), "--profile", "p"],
|
p = subprocess.Popen([orch, "run", str(task("killed", "HANG")), "--repo", str(repo), "--profile", "p"],
|
||||||
|
|||||||
Reference in new issue
Block a user