mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 20:34:17 +01:00
Every first install of v1.18.7 stopped at step 7 with "Install failed at line 1411 (command: OC_SUM_BEFORE="$(oc_configs_sum)")": the fingerprint of the two configs opencode-web reads ran cat on both, neither exists on a box with nothing installed, cat failed, pipefail failed the pipeline, and set -e ended the run. Found by running the one-liner on the reference box with its install moved aside, 2026-09-30. Only runs where both files already existed, updates of older installs, got through. A missing file is now part of the fingerprint instead of a failure, in install.sh and in switch-model.sh, which carried the same two lines. The suite never saw it because every run of install.sh it makes stops before step 1; the new test runs each script's own lines under its own shell options from an empty HOME, and fails 5 of 5 on the previous revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
3.6 KiB
Python
86 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""A first install gets past the opencode step, where neither opencode config exists yet.
|
|
|
|
Step 7 fingerprints the two configs opencode-web reads, to restart the server only when one
|
|
of them changed: `OC_SUM_BEFORE="$(oc_configs_sum)"`, whose body was `cat A B | sha256sum`.
|
|
On a box with nothing installed neither file exists, cat fails, pipefail makes the pipeline
|
|
fail, the assignment returns that status, and set -e ended the install there: every first
|
|
install of v1.18.7 stopped at "Install failed at line 1411" (the reference box, emptied for
|
|
the test, 2026-09-30). The suite never saw it, because every run of install.sh it makes
|
|
stops before step 1. switch-model.sh carried the same two lines.
|
|
|
|
These run each script's own lines under its own shell options, from an empty HOME.
|
|
"""
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def lines(script):
|
|
"""The script's oc_configs_sum definition and the assignment that calls it first."""
|
|
text = (REPO / script).read_text().splitlines()
|
|
i = next(n for n, ln in enumerate(text) if ln.startswith("oc_configs_sum(){"))
|
|
call = next(ln for ln in text[i + 1:] if '="$(oc_configs_sum)"' in ln)
|
|
return text[i], call.strip()
|
|
|
|
|
|
def run(script, files=()):
|
|
"""(returncode, stdout) of the two lines under set -euo pipefail, from an empty HOME
|
|
and an empty config dir holding `files` ({path relative to HOME: text})."""
|
|
home = pathlib.Path(tempfile.mkdtemp(prefix="first-run-home-"))
|
|
for rel, body in dict(files).items():
|
|
(home / rel).parent.mkdir(parents=True, exist_ok=True)
|
|
(home / rel).write_text(body)
|
|
define, call = lines(script)
|
|
var = call.split("=", 1)[0]
|
|
body = (f"set -euo pipefail\nCONFIG_DIR=\"$HOME/.config/qwen38\"\n{define}\n{call}\n"
|
|
f'echo "REACHED ${var}"\n')
|
|
r = subprocess.run(["bash", "-c", body], capture_output=True, text=True, timeout=30,
|
|
env={"PATH": "/usr/bin:/bin", "HOME": str(home)})
|
|
return r.returncode, r.stdout
|
|
|
|
|
|
class TheFirstInstallGetsPastTheOpencodeStep(unittest.TestCase):
|
|
def test_install_with_neither_config(self):
|
|
rc, out = run("install.sh")
|
|
self.assertEqual(rc, 0, "set -e ended the first install at the fingerprint")
|
|
self.assertIn("REACHED ", out)
|
|
|
|
def test_install_with_only_the_users_own_config(self):
|
|
# opencode used before this repo: its own config is there, the repo's is not yet
|
|
rc, out = run("install.sh", {".config/opencode/opencode.json": "{}\n"})
|
|
self.assertEqual(rc, 0)
|
|
|
|
def test_switch_with_one_config_gone(self):
|
|
rc, out = run("switch-model.sh", {".config/qwen38/opencode.json": "{}\n"})
|
|
self.assertEqual(rc, 0)
|
|
|
|
|
|
class TheFingerprintStillSeesAChange(unittest.TestCase):
|
|
"""What the fingerprint is for: a config that appears or changes reads different."""
|
|
|
|
def sums(self, script):
|
|
seen = []
|
|
for files in ({}, {".config/qwen38/opencode.json": "{}\n"},
|
|
{".config/qwen38/opencode.json": "{}\n", ".config/opencode/opencode.json": "{}\n"},
|
|
{".config/qwen38/opencode.json": "{ }\n", ".config/opencode/opencode.json": "{}\n"}):
|
|
rc, out = run(script, files)
|
|
self.assertEqual(rc, 0)
|
|
seen.append(out.split("REACHED ", 1)[1].strip())
|
|
return seen
|
|
|
|
def test_install(self):
|
|
seen = self.sums("install.sh")
|
|
self.assertEqual(len(set(seen)), 4, seen)
|
|
|
|
def test_switch(self):
|
|
seen = self.sums("switch-model.sh")
|
|
self.assertEqual(len(set(seen)), 4, seen)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|