diff --git a/host-setup/windows/install-tools.ps1 b/host-setup/windows/install-tools.ps1 index 2ba310256..f58ad1bf0 100644 --- a/host-setup/windows/install-tools.ps1 +++ b/host-setup/windows/install-tools.ps1 @@ -496,10 +496,10 @@ function Get-InstallerFailureReason { $result.Entries = $selected.Entries $result.InUse = $selected.InUse } - $idPattern = "(?i)(? None: in_use = $reason.InUse } } +$held = [System.IO.File]::Open((Join-Path $case.directory $case.locked), 'Open', 'Read', 'None') +try { + $reason = Get-InstallerFailureReason -Id 'Locked.Tool' -Since ([datetime]'2000-01-01') -Directory $case.directory + $results['locked'] = [ordered]@{ winget_log = [bool]$reason.WingetLog; winget_entries = @($reason.WingetEntries) } +} finally { + $held.Dispose() +} $env:ProgramFiles = 'C:\PF' ${env:ProgramFiles(x86)} = 'C:\PF86' $env:LOCALAPPDATA = 'C:\LAD' @@ -940,6 +947,22 @@ def test_the_note_follows_what_dotnet_lists(self) -> None: "2026-01-02 03:04:05.300 [CLI ] Caught std::exception: remove: Access is denied.", ] +HYPHEN_NEIGHBOR_WINGET_LOG = [ + "2026-01-02 03:04:05.100 [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Portable.Tool-Extra'", + "2026-01-02 03:04:05.200 [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Vendor-Portable.Tool'", + "2026-01-02 03:04:05.300 [CLI ] A neighboring package's own failure.", +] + +READABLE_WINGET_LOG = [ + "2026-01-02 03:04:05.100 [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Locked.Tool'", + "2026-01-02 03:04:05.300 [CLI ] The readable log's failure.", +] + +LOCKED_WINGET_LOG = [ + "2026-01-02 03:04:05.100 [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Locked.Tool'", + "2026-01-02 03:04:05.300 [CLI ] The locked log's failure.", +] + UNRELATED_DENIAL_WINGET_LOG = [ "2026-01-02 03:04:05.100 [CLI ] WinGet invoked with arguments: 'install' '--id' 'Settings.Tool'", "2026-01-02 03:04:05.300 [CORE] Failed to open the settings store: Access is denied.", @@ -976,6 +999,9 @@ def run_cases(self) -> dict[str, Any]: ("WinGet-2026-01-02-03-04-05.000.log", PORTABLE_WINGET_LOG), ("WinGet-2026-01-02-03-04-06.000.log", OTHER_WINGET_LOG), ("WinGet-2026-01-02-03-04-07.000.log", UNRELATED_DENIAL_WINGET_LOG), + ("WinGet-2026-01-02-03-04-08.000.log", HYPHEN_NEIGHBOR_WINGET_LOG), + ("WinGet-2026-01-02-03-04-09.000.log", READABLE_WINGET_LOG), + ("WinGet-2026-01-02-03-04-10.000.log", LOCKED_WINGET_LOG), ): Path(directory, name).write_text( "\r\n".join([*lines, ""]), encoding="utf-8", newline="" @@ -985,6 +1011,7 @@ def run_cases(self) -> dict[str, Any]: elsewhere.write_bytes(b"") cases = { "directory": directory, + "locked": "WinGet-2026-01-02-03-04-10.000.log", "reasons": [ {"id": "Example.Tool", "since": "2000-01-01"}, {"id": "Example.Tool", "since": "2100-01-01"}, @@ -1060,6 +1087,13 @@ def test_an_installer_logs_access_denial_alone_is_not_files_in_use(self) -> None }, ) + def test_a_winget_log_nothing_can_read_leaves_the_readable_one_to_report(self) -> None: + """A locked log is skipped like an absent one, so the failure report still runs.""" + self.assertEqual( + self.run_cases()["locked"], + {"winget_log": True, "winget_entries": ["The readable log's failure."]}, + ) + def test_a_winget_denial_naming_no_file_is_not_files_in_use(self) -> None: """Only a denial naming a file is winget failing to replace one.""" self.assertEqual( diff --git a/tests/test_skills_install.py b/tests/test_skills_install.py index 03c17259e..1b3772e69 100755 --- a/tests/test_skills_install.py +++ b/tests/test_skills_install.py @@ -875,6 +875,14 @@ def test_an_unreadable_listing_is_unknown_rather_than_not_installed(self) -> Non ).start() self.assertEqual(skills_install.plugin_state(), {"installed": None, "enabled": None}) + def test_a_listing_that_does_not_decode_is_unknown(self) -> None: + """A real child, since a decode failure is what the reader thread once swallowed.""" + with mock.patch("shutil.which", return_value=sys.executable): + listing = skills_install.claude_json( + "-c", "import sys; sys.stdout.buffer.write(bytes([255]))" + ) + self.assertIsNone(listing) + def test_the_live_channel_carries_the_state_only_where_registered(self) -> None: mock.patch("skills_install.claude_available", return_value=True).start() state = {"installed": True, "enabled": False}