37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
import manage
|
|
|
|
|
|
class InstallationTests(unittest.TestCase):
|
|
def test_standard_installer_needs_only_go_and_honors_gobin(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root=Path(directory)
|
|
capture=root/"args"
|
|
executable=root/"go"
|
|
executable.write_text('#!/bin/sh\nprintf "%s\\n" "$GOBIN" "$@" >> "'+str(capture)+'"\n')
|
|
executable.chmod(0o700)
|
|
env=dict(os.environ,PATH=str(root)+os.pathsep+os.environ["PATH"],GOBIN=str(root/"bin"))
|
|
subprocess.run([str(Path(__file__).resolve().parents[1]/"install.sh")],env=env,check=True)
|
|
self.assertEqual(capture.read_text().splitlines(),[str(root/"bin"),"install","-trimpath","./cmd/...",str(root/"bin"),"run","./cmd/pipelines","skill","install"])
|
|
self.assertFalse((root/"bin").exists())
|
|
|
|
def test_standard_installer_rejects_legacy_provisioning_flags(self):
|
|
result=subprocess.run([str(Path(__file__).resolve().parents[1]/"install.sh"),"--system-command"],capture_output=True,text=True)
|
|
self.assertEqual(result.returncode,2)
|
|
self.assertIn("GOBIN",result.stderr)
|
|
|
|
def test_legacy_management_requires_owned_marker(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
with self.assertRaises(ValueError):manage.load(directory)
|
|
|
|
def test_legacy_pid_reuse_cannot_signal_unrelated_process(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
Path(directory,"supervisor.pid").write_text(str(os.getpid()))
|
|
self.assertIsNone(manage.managed_pid(dict(prefix=directory)))
|
|
|
|
if __name__=="__main__":unittest.main()
|