tools: register the updater in the normal command path (#24)
Use /usr/local/bin for container updater discovery and print an absolute command path for custom shells. Preserve managed links and operator files; cover shell lookup without sbin. Closes #23
This commit was merged in pull request #24.
This commit is contained in:
@@ -299,6 +299,37 @@ class GuestTests(unittest.TestCase):
|
||||
guest.install_updater()
|
||||
self.assertEqual(b"operator file", path.read_bytes())
|
||||
|
||||
def test_updater_is_discoverable_without_sbin_in_shell_path(self):
|
||||
git = shutil.which("git")
|
||||
windows_bash = Path(git).resolve().parents[1] / "bin/bash.exe" if git else Path("missing")
|
||||
bash = str(windows_bash) if os.name == "nt" and windows_bash.is_file() else shutil.which("bash")
|
||||
self.assertIsNotNone(bash, "Bash is required for container command lookup verification")
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
app = root / "app"
|
||||
target = app / "current/finaltoken-update"
|
||||
target.parent.mkdir(parents=True)
|
||||
target.write_bytes(b"#!/bin/sh\nprintf 'synthetic updater executed\\n'\n")
|
||||
target.chmod(0o755)
|
||||
registered = root / guest.UPDATER.as_posix().lstrip("/")
|
||||
searched = root / "usr/local/bin"
|
||||
searched.mkdir(parents=True)
|
||||
with contextlib.ExitStack() as stack:
|
||||
stack.enter_context(patch.object(guest, "APP", app))
|
||||
stack.enter_context(patch.object(guest, "UPDATER", registered))
|
||||
if os.name == "nt":
|
||||
# Windows may deny symlink creation; only substitute that OS operation.
|
||||
# The real Bash lookup/execution still uses the actual installed path.
|
||||
stack.enter_context(patch.object(Path, "symlink_to", lambda path, destination: shutil.copy2(destination, path)))
|
||||
guest.install_updater()
|
||||
env = dict(os.environ, PATH=str(searched))
|
||||
env.pop("BASH_ENV", None)
|
||||
result = subprocess.run([bash, "--noprofile", "--norc", "-c",
|
||||
"command -v finaltoken-update && finaltoken-update"], env=env,
|
||||
text=True, capture_output=True, timeout=10)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
self.assertIn("synthetic updater executed", result.stdout)
|
||||
|
||||
def test_codex_npm_install_creates_the_configured_launcher(self):
|
||||
node, npm = shutil.which("node"), shutil.which("npm")
|
||||
if not node or not npm:
|
||||
|
||||
Reference in New Issue
Block a user