From 95e84418eda84b9be39d9dc4dd3ceaed4a76fb84 Mon Sep 17 00:00:00 2001 From: Jesper Schulz-Wedde Date: Thu, 4 Jun 2026 15:00:12 +0200 Subject: [PATCH] Resolve knowledge-index root to absolute path (cross-platform fix) Get-ChildItem.FullName is always absolute, so deriving the relative article path via Substring(\.Length) requires an absolute root. A relative root such as '.' (used by the CI guard's 'Test-KnowledgeIndex.ps1 -Root .') left the full path almost intact on Linux, producing bogus 'home/runner/.../knowledge' paths and failing the coverage check. Normalise both the generator's -BCQualityRoot and the test's -Root with Resolve-Path before use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/Test-KnowledgeIndex.ps1 | 4 ++++ tools/Build-KnowledgeIndex.ps1 | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/scripts/Test-KnowledgeIndex.ps1 b/.github/scripts/Test-KnowledgeIndex.ps1 index 224b010..76896af 100644 --- a/.github/scripts/Test-KnowledgeIndex.ps1 +++ b/.github/scripts/Test-KnowledgeIndex.ps1 @@ -27,6 +27,10 @@ param( Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' +# Normalise to an absolute path so Substring-based relative-path derivation +# below matches the absolute FullName the generator emits (CI passes -Root .). +$Root = (Resolve-Path -LiteralPath $Root).Path + $generator = Join-Path $Root 'tools/Build-KnowledgeIndex.ps1' if (-not (Test-Path $generator)) { throw "Generator not found: $generator" } diff --git a/tools/Build-KnowledgeIndex.ps1 b/tools/Build-KnowledgeIndex.ps1 index 09758b9..5835e5d 100644 --- a/tools/Build-KnowledgeIndex.ps1 +++ b/tools/Build-KnowledgeIndex.ps1 @@ -79,6 +79,10 @@ if (-not $BCQualityRoot) { if (-not (Test-Path $BCQualityRoot)) { throw "BCQuality root not found: $BCQualityRoot" } +# Normalise to an absolute path: Get-ChildItem.FullName below is always +# absolute, so Get-RelativePath's Substring needs an absolute root to strip. +# A relative root (e.g. '.') would otherwise leave the full path intact. +$BCQualityRoot = (Resolve-Path -LiteralPath $BCQualityRoot).Path if (-not $IndexPath) { $IndexPath = Join-Path $BCQualityRoot 'knowledge-index.json' }