Skip to content

Commit 7388921

Browse files
authored
Merge pull request DeusData#639 from Flipper1994/windows-red-tests-20260627
test(windows): add red regressions for platform-specific failures
2 parents 093eaf1 + 0eb2c58 commit 7388921

9 files changed

Lines changed: 1242 additions & 0 deletions

File tree

‎.github/workflows/_test.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,43 @@ jobs:
124124
run: scripts/test.sh CC=clang CXX=clang++ ${{ matrix.os == 'windows-11-arm' && 'SANITIZE=' || '' }}
125125
env:
126126
CBM_SKIP_PERF: ${{ inputs.skip_perf && '1' || '' }}
127+
128+
# Windows product-surface regression guards. Distinct from test-windows above
129+
# (the sanitizer C suite): these drive a real product binary + embedded HTTP UI
130+
# over stdio / CLI / HTTP and fail if a Windows bug already fixed on main comes
131+
# back -- non-ASCII repo paths dropping definitions (#636/#357, fixed by #700),
132+
# the PreToolUse hook augmenter no-op on drive-letter cwd (#618, fixed by #619),
133+
# and the UI directory picker not enumerating drives (#548, roots field). The
134+
# still-open narrow-argv repro (#423/#20) is opt-in and excluded via -GuardsOnly.
135+
test-windows-guards:
136+
runs-on: windows-latest
137+
timeout-minutes: 60
138+
steps:
139+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
140+
141+
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
142+
with:
143+
msystem: CLANG64
144+
path-type: inherit
145+
install: >-
146+
mingw-w64-clang-x86_64-clang
147+
mingw-w64-clang-x86_64-zlib
148+
make
149+
git
150+
151+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
152+
with:
153+
node-version: "22"
154+
155+
- name: Build product binary with embedded UI
156+
shell: msys2 {0}
157+
# --with-ui builds the frontend (npm) and embeds it, so the drive-picker
158+
# guard's HTTP UI is available. Functional gate only (no sanitizers).
159+
run: scripts/build.sh --with-ui CC=clang CXX=clang++
160+
161+
- name: Windows regression guards (#636/#357, #618, #548)
162+
shell: pwsh
163+
# -GuardsOnly runs the three green guards and gates on them; the runner
164+
# runs indexing in-process (CBM_INDEX_SUPERVISOR=0) so a guard reflects the
165+
# path/hook/drive fix under test, not the orthogonal index-worker spawn.
166+
run: ./scripts/test-windows.ps1 -GuardsOnly -Binary build/c/codebase-memory-mcp.exe

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ soak-results/
6262

6363
# Local npm cache
6464
graph-ui/.npm-cache-local/
65+
66+
# Python bytecode from tests/windows/ harness
67+
__pycache__/
68+
*.pyc

‎scripts/test-windows.ps1‎

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<#
2+
.SYNOPSIS
3+
Run the native-Windows product-surface test suite for codebase-memory-mcp.
4+
5+
.DESCRIPTION
6+
Builds the product binary (build/c/codebase-memory-mcp.exe) if it is not
7+
already present, then runs the deterministic Windows integration tests under
8+
tests/windows/ against a real codebase-memory-mcp.exe (real stdio / CLI /
9+
HTTP UI, real SQLite DB).
10+
11+
Two categories of test:
12+
13+
GUARDS - regression guards for Windows bugs already fixed on main.
14+
They must stay GREEN (exit 0); a RED (exit 1) means the fix
15+
regressed and fails this runner.
16+
* test_non_ascii_path.py guards #636/#357 (fixed by #700)
17+
* test_hook_augment.py guards #618 (fixed by #619)
18+
* test_ui_drive_listing.py guards #548 (roots field)
19+
20+
KNOWN REDS - genuine, still-open Windows bugs reproduced at the product
21+
surface. They are EXPECTED to be RED (exit 1) and are opt-in
22+
(never gate CI). If one turns GREEN the underlying bug was
23+
fixed and it should be promoted to a guard.
24+
* test_cli_non_ascii_arg.py reproduces #423/#20 (narrow
25+
argv main() - no wide command line)
26+
27+
Determinism: indexing runs in-process (CBM_INDEX_SUPERVISOR=0). These tests
28+
exercise path / hook / drive handling, not the index-supervisor subprocess
29+
path; the pass-level readers (#700's cbm_fopen routing) run in-process either
30+
way, so the guard coverage is identical while results stay independent of the
31+
local toolchain's worker-spawn behavior.
32+
33+
On native Windows the MinGW/LLVM toolchain ships no libasan/libubsan, so the
34+
build disables sanitizers (SANITIZE=). Where the toolchain provides
35+
AddressSanitizer/UBSan (Linux containers, WSL), prefer scripts/test.sh.
36+
37+
.PARAMETER Binary
38+
Path to an existing codebase-memory-mcp.exe. If omitted, the script builds it
39+
(target selected by -Target) into build/c/.
40+
41+
.PARAMETER Target
42+
Makefile.cbm target used when building: 'cbm-with-ui' (default; needed for the
43+
drive-picker guard's embedded HTTP UI) or 'cbm' (no UI - the drive guard then
44+
reports a precondition and is skipped).
45+
46+
.PARAMETER GuardsOnly
47+
Run only the green guards (the CI gate). Skips the opt-in known-red repros.
48+
49+
.PARAMETER Make
50+
Path to GNU make (default: 'make' on PATH; MSYS2 ships it at
51+
C:\msys64\usr\bin\make.exe).
52+
53+
.EXAMPLE
54+
pwsh -File scripts/test-windows.ps1
55+
.EXAMPLE
56+
pwsh -File scripts/test-windows.ps1 -GuardsOnly -Binary build\c\codebase-memory-mcp.exe
57+
#>
58+
[CmdletBinding()]
59+
param(
60+
[string]$Binary,
61+
[ValidateSet("cbm-with-ui", "cbm")]
62+
[string]$Target = "cbm-with-ui",
63+
[switch]$GuardsOnly,
64+
[string]$Make = "make"
65+
)
66+
67+
$ErrorActionPreference = "Stop"
68+
$repoRoot = Split-Path -Parent $PSScriptRoot
69+
Set-Location $repoRoot
70+
71+
$python = (Get-Command python -ErrorAction SilentlyContinue)
72+
if (-not $python) { $python = (Get-Command py -ErrorAction SilentlyContinue) }
73+
if (-not $python) { throw "Python 3 is required to run the Windows tests." }
74+
$py = $python.Source
75+
76+
# A writable Windows temp dir that GNU make forwards to the native gcc. MSYS2
77+
# strips TMP/TEMP from the environment it hands native children, so pass them as
78+
# make command-line variables (make exports those to recipe processes).
79+
$tmp = $env:TEMP
80+
if (-not $tmp) { $tmp = "$env:USERPROFILE\AppData\Local\Temp" }
81+
82+
function Resolve-Binary {
83+
param([string]$Explicit)
84+
if ($Explicit) { return (Resolve-Path $Explicit).Path }
85+
$built = Join-Path $repoRoot "build\c\codebase-memory-mcp.exe"
86+
if (Test-Path $built) { return $built }
87+
Write-Host "Building $Target via Makefile.cbm ..." -ForegroundColor Cyan
88+
& $Make "-j" "-f" "Makefile.cbm" $Target "SANITIZE=" "TMP=$tmp" "TEMP=$tmp" "TMPDIR=$tmp"
89+
if ($LASTEXITCODE -ne 0) { throw "build failed (exit $LASTEXITCODE)" }
90+
if (-not (Test-Path $built)) { throw "binary not produced at $built" }
91+
return $built
92+
}
93+
94+
$bin = Resolve-Binary -Explicit $Binary
95+
Write-Host "Binary: $bin" -ForegroundColor Green
96+
97+
$env:PYTHONUTF8 = "1" # encode argv/stdio as UTF-8
98+
$env:CBM_INDEX_SUPERVISOR = "0" # in-process indexing (see .DESCRIPTION)
99+
100+
# Green regression guards - must stay GREEN (exit 0). RED (exit 1) = the fix for
101+
# the referenced issue regressed. The drive-picker guard needs the embedded HTTP
102+
# UI (build target cbm-with-ui); against a non-UI binary it reports a precondition
103+
# (exit 2) and is skipped rather than failed.
104+
$guards = @(
105+
"tests\windows\test_non_ascii_path.py",
106+
"tests\windows\test_hook_augment.py",
107+
"tests\windows\test_ui_drive_listing.py"
108+
)
109+
110+
# Opt-in known-red repros - EXPECTED red (exit 1); never gate CI.
111+
$knownReds = @(
112+
"tests\windows\test_cli_non_ascii_arg.py"
113+
)
114+
115+
$guardFailures = @()
116+
$guardSkips = @()
117+
$fixedKeepers = @()
118+
119+
Write-Host "`n--- Green guards ---" -ForegroundColor Cyan
120+
foreach ($t in $guards) {
121+
Write-Host "`n=== $t ===" -ForegroundColor Cyan
122+
& $py $t $bin
123+
$code = $LASTEXITCODE
124+
if ($code -eq 0) {
125+
Write-Host "GREEN ($t)" -ForegroundColor Green
126+
} elseif ($code -eq 1) {
127+
Write-Host "RED ($t) - REGRESSION: a fixed Windows bug is broken again" -ForegroundColor Red
128+
$guardFailures += $t
129+
} else {
130+
Write-Host "PRECONDITION ($t) exit=$code - skipped (see message above)" -ForegroundColor Yellow
131+
$guardSkips += $t
132+
}
133+
}
134+
135+
if (-not $GuardsOnly) {
136+
Write-Host "`n--- Known reds (opt-in, expected red) ---" -ForegroundColor Cyan
137+
foreach ($t in $knownReds) {
138+
Write-Host "`n=== $t ===" -ForegroundColor Cyan
139+
& $py $t $bin
140+
$code = $LASTEXITCODE
141+
if ($code -eq 1) {
142+
Write-Host "RED ($t) - expected; the underlying Windows bug is still open" -ForegroundColor DarkYellow
143+
} elseif ($code -eq 0) {
144+
Write-Host "GREEN ($t) - the bug appears FIXED; promote this to a guard" -ForegroundColor Green
145+
$fixedKeepers += $t
146+
} else {
147+
Write-Host "PRECONDITION ($t) exit=$code - skipped (see message above)" -ForegroundColor Yellow
148+
}
149+
}
150+
}
151+
152+
Write-Host ""
153+
if ($guardSkips.Count -gt 0) {
154+
Write-Host ("Guards skipped (precondition): {0} - e.g. the drive-picker guard " -f $guardSkips.Count) -ForegroundColor Yellow
155+
Write-Host "needs a UI build (-Target cbm-with-ui, the default)." -ForegroundColor Yellow
156+
}
157+
if ($fixedKeepers.Count -gt 0) {
158+
Write-Host ("Known-red repros that are now GREEN (promote to guards): {0}" -f ($fixedKeepers -join ", ")) -ForegroundColor Green
159+
}
160+
if ($guardFailures.Count -gt 0) {
161+
Write-Host ("REGRESSION: {0} green guard(s) went red: {1}" -f $guardFailures.Count, ($guardFailures -join ", ")) -ForegroundColor Red
162+
Write-Host "A previously-fixed Windows bug is broken again. See tests/windows/RED_TEST_ANALYSIS.md." -ForegroundColor Red
163+
exit 1
164+
}
165+
Write-Host "All Windows green guards passed." -ForegroundColor Green
166+
exit 0

0 commit comments

Comments
 (0)