| 113 | # No docker on this runner. The install.ps1 and Codeplain CLI runs directly on the windows VM. |
| 114 | @pytest.fixture(scope="session") |
| 115 | def codeplain_exe(api_key: str) -> Path: |
| 116 | if sys.platform != "win32": |
| 117 | pytest.skip("Windows-only fixture") |
| 118 | |
| 119 | env = { |
| 120 | **os.environ, |
| 121 | "CODEPLAIN_API_KEY": api_key, |
| 122 | "CODEPLAIN_INSTALL_NONINTERACTIVE": "1", |
| 123 | } |
| 124 | result = subprocess.run( |
| 125 | ["pwsh", "-NoProfile", "-File", str(INSTALL_PS1)], |
| 126 | capture_output=True, |
| 127 | text=True, |
| 128 | timeout=600, |
| 129 | env=env, |
| 130 | check=False, |
| 131 | ) |
| 132 | if result.returncode != 0: |
| 133 | pytest.fail( |
| 134 | f"install.ps1 failed (rc={result.returncode})\n" f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" |
| 135 | ) |
| 136 | |
| 137 | # uv tool installs binaries to %USERPROFILE%\.local\bin (see install.ps1 |
| 138 | # line ~102). Resolve the absolute path so our subprocess doesn't depend |
| 139 | # on the current process's stale PATH — install.ps1 writes the user PATH |
| 140 | # to the registry, but the python process running pytest already cached |
| 141 | # its env at startup. |
| 142 | exe = Path(os.environ["USERPROFILE"]) / ".local" / "bin" / "codeplain.exe" |
| 143 | if not exe.exists(): |
| 144 | pytest.fail(f"codeplain.exe not found at expected location: {exe}") |
| 145 | return exe |