(
install_dir: Path,
timeout: int = 420,
check: bool = True,
options: list | None = None,
)
| 224 | |
| 225 | |
| 226 | def _run_uninstaller_exe( |
| 227 | install_dir: Path, |
| 228 | timeout: int = 420, |
| 229 | check: bool = True, |
| 230 | options: list | None = None, |
| 231 | ) -> subprocess.CompletedProcess | None: |
| 232 | # Now test the uninstallers |
| 233 | if " " in str(install_dir): |
| 234 | # TODO: We can't seem to run the uninstaller when there are spaces in the PATH |
| 235 | warnings.warn( |
| 236 | f"Skipping uninstaller tests for '{install_dir}' due to spaces in path. " |
| 237 | "This is a known issue with our setup, to be fixed." |
| 238 | ) |
| 239 | return |
| 240 | options = options or [] |
| 241 | # Rename install.log |
| 242 | install_log = install_dir / "install.log" |
| 243 | if install_log.exists(): |
| 244 | install_log.rename(install_dir / "install.log.bak") |
| 245 | |
| 246 | uninstaller = next(install_dir.glob("Uninstall-*.exe"), None) |
| 247 | if not uninstaller: |
| 248 | raise AssertionError("Could not find uninstaller!") |
| 249 | cmd = [ |
| 250 | "cmd.exe", |
| 251 | "/c", |
| 252 | "start", |
| 253 | "/wait", |
| 254 | str(uninstaller), |
| 255 | "/S", |
| 256 | *options, |
| 257 | # We need silent mode + "uninstaller location" (_?=...) so the command can |
| 258 | # be waited; otherwise, since the uninstaller copies itself to a different |
| 259 | # location so it can be auto-deleted, it returns immediately and it gives |
| 260 | # us problems with the tempdir cleanup later |
| 261 | f"_?={install_dir}", |
| 262 | ] |
| 263 | process = _execute(cmd, timeout=timeout, check=check) |
| 264 | if check and Path(install_dir, "install.log").exists(): |
| 265 | _check_installer_log(install_dir) |
| 266 | remaining_files = list(install_dir.iterdir()) |
| 267 | if len(remaining_files) > 3: |
| 268 | # The debug installer writes to install.log too, which will only |
| 269 | # be deleted _after_ a reboot. Finding some files is ok, but more |
| 270 | # than two usually means a problem with the uninstaller. |
| 271 | # Note this is is not exhaustive, because we are not checking |
| 272 | # whether the registry was restored, menu items were deleted, etc. |
| 273 | # TODO :) |
| 274 | raise AssertionError(f"Uninstaller left too many files: {remaining_files}") |
| 275 | return process |
| 276 | |
| 277 | |
| 278 | def _run_installer_sh( |
no test coverage detected