Generates the plugin into a throwaway HOME using the real installer.
(work: Path)
| 43 | |
| 44 | |
| 45 | def generate_plugin(work: Path) -> Path: |
| 46 | """Generates the plugin into a throwaway HOME using the real installer.""" |
| 47 | repo_root = Path(__file__).resolve().parent.parent |
| 48 | bin_path = Path( |
| 49 | os.environ.get("TRACEDECAY_BIN", repo_root / "target" / "debug" / "tracedecay") |
| 50 | ) |
| 51 | assert bin_path.is_file(), f"tracedecay binary not found at {bin_path}" |
| 52 | home = work / "home" |
| 53 | home.mkdir() |
| 54 | env = dict(os.environ) |
| 55 | env["HOME"] = str(home) |
| 56 | env["USERPROFILE"] = str(home) |
| 57 | env["PATH"] = f"{bin_path.parent}{os.pathsep}{env.get('PATH', '')}" |
| 58 | env.pop("HERMES_HOME", None) |
| 59 | subprocess.run( |
| 60 | [str(bin_path), "install", "--agent", "hermes", "--no-dashboard"], |
| 61 | check=True, |
| 62 | env=env, |
| 63 | capture_output=True, |
| 64 | text=True, |
| 65 | timeout=120, |
| 66 | ) |
| 67 | plugin_dir = home / ".hermes" / "plugins" / "tracedecay" |
| 68 | assert (plugin_dir / "__init__.py").is_file(), plugin_dir |
| 69 | return plugin_dir |
| 70 | |
| 71 | |
| 72 | class StubCtx: |
no test coverage detected