Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions host-setup/windows/install-tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ function Get-InstallerFailureReason {
$result.Entries = $selected.Entries
$result.InUse = $selected.InUse
}
$idPattern = "(?i)(?<![\w.])$([regex]::Escape($Id))(?![\w.])"
$idPattern = "(?i)(?<![\w.-])$([regex]::Escape($Id))(?![\w.-])"
$session = Get-ChildItem -LiteralPath $Directory -Filter 'WinGet-*.log' -File -ErrorAction SilentlyContinue |
Where-Object { $_.CreationTime -ge $Since } | Sort-Object CreationTime, Name -Descending |
Where-Object { Select-String -LiteralPath $_.FullName -Pattern $idPattern -Quiet } | Select-Object -First 1
Where-Object { Select-String -LiteralPath $_.FullName -Pattern $idPattern -Quiet -ErrorAction SilentlyContinue } | Select-Object -First 1
if ($session) {
$result.WingetLog = $session.FullName
$errors = @(Get-Content -LiteralPath $session.FullName -ErrorAction SilentlyContinue |
Expand Down
7 changes: 5 additions & 2 deletions scripts/skills_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ def run_with_deadline(argv):


def git_in(root, *args):
"""Run git against `root`, returning stripped stdout, or None on any failure."""
"""Run git against `root`, returning stripped stdout, or None on a failure.

Output that does not decode raises instead, since None could read as a clean tree.
"""
try:
r = run_with_deadline(["git", "-C", str(root), *args])
except UnicodeDecodeError:
Expand Down Expand Up @@ -246,7 +249,7 @@ def claude_json(*args):
try:
listing = run_with_deadline(claude_argv(*args))
entries = json.loads(listing.stdout) if listing.returncode == 0 else None
except (OSError, subprocess.TimeoutExpired, json.JSONDecodeError):
except (OSError, subprocess.TimeoutExpired, ValueError):
return None
return entries if isinstance(entries, list) else None

Expand Down
34 changes: 34 additions & 0 deletions tests/test_install_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,13 @@ def test_the_note_follows_what_dotnet_lists(self) -> 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'
Expand Down Expand Up @@ -940,6 +947,22 @@ def test_the_note_follows_what_dotnet_lists(self) -> None:
"2026-01-02 03:04:05.300 <E> [CLI ] Caught std::exception: remove: Access is denied.",
]

HYPHEN_NEIGHBOR_WINGET_LOG = [
"2026-01-02 03:04:05.100 <I> [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Portable.Tool-Extra'",
"2026-01-02 03:04:05.200 <I> [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Vendor-Portable.Tool'",
"2026-01-02 03:04:05.300 <E> [CLI ] A neighboring package's own failure.",
]

READABLE_WINGET_LOG = [
"2026-01-02 03:04:05.100 <I> [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Locked.Tool'",
"2026-01-02 03:04:05.300 <E> [CLI ] The readable log's failure.",
]

LOCKED_WINGET_LOG = [
"2026-01-02 03:04:05.100 <I> [CLI ] WinGet invoked with arguments: 'upgrade' '--id' 'Locked.Tool'",
"2026-01-02 03:04:05.300 <E> [CLI ] The locked log's failure.",
]

UNRELATED_DENIAL_WINGET_LOG = [
"2026-01-02 03:04:05.100 <I> [CLI ] WinGet invoked with arguments: 'install' '--id' 'Settings.Tool'",
"2026-01-02 03:04:05.300 <E> [CORE] Failed to open the settings store: Access is denied.",
Expand Down Expand Up @@ -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=""
Expand All @@ -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"},
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions tests/test_skills_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading