From c4e74a07639594825002756123bb6cee78fd0007 Mon Sep 17 00:00:00 2001 From: Phil Carbone Date: Sat, 7 Feb 2026 16:25:38 -0500 Subject: [PATCH] fix(scripts): Add primary DLL filter for accurate test discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Test-IsPrimaryTestDll function to filter out copied DLLs from other projects' bin folders (e.g., Whizbang.Core.Tests.dll copied to Whizbang.Data.Tests/bin/ due to project references) - Replace --solution flag with explicit DLL discovery for AiFull/Full modes to avoid picking up library projects like Whizbang.Testing - Apply primary DLL filter to both integration-excluded and integration-included test discovery paths This ensures each test DLL is only run from its primary project location, preventing duplicate test execution and fixing the "Unable to proceed with project Whizbang.Testing" error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- scripts/Run-Tests.ps1 | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/Run-Tests.ps1 b/scripts/Run-Tests.ps1 index 70b66512..3cb7d0ef 100755 --- a/scripts/Run-Tests.ps1 +++ b/scripts/Run-Tests.ps1 @@ -461,6 +461,17 @@ try { } } + # Helper function to check if a DLL is in its primary project location (not copied to another project's bin folder) + # When project A references project B, B's DLL gets copied to A's bin folder. This causes duplicate test discovery. + # We only want to run each test DLL from its primary location (where DLL name matches project folder name). + function Test-IsPrimaryTestDll { + param([System.IO.FileInfo]$DllFile) + $dllName = [System.IO.Path]::GetFileNameWithoutExtension($DllFile.Name) + $projectDir = $DllFile.DirectoryName -replace "[/\\]bin[/\\]Debug[/\\]net10\.0$", "" + $projectName = [System.IO.Path]::GetFileName($projectDir) + return $dllName -eq $projectName + } + # Use --test-modules with globbing pattern for project filtering if ($ProjectFilter) { # Native .NET 10 globbing: **/bin/**/Debug/net10.0/*{Filter}*.dll @@ -496,6 +507,7 @@ try { # Pattern: bin/Debug/net10.0/ - works for standard .NET output paths $allTestDlls = @(Get-ChildItem -Path $repoRoot -Recurse -Filter "*.Tests.dll" -ErrorAction SilentlyContinue | Where-Object { $_.FullName -match "bin[/\\]Debug[/\\]net10\.0[/\\]" } | + Where-Object { Test-IsPrimaryTestDll $_ } | Where-Object { -not (Test-IsIntegrationTest $_.Name) } | ForEach-Object { [System.IO.Path]::GetRelativePath($repoRoot, $_.FullName) }) @@ -512,9 +524,26 @@ try { exit 1 } } else { - # Use the main solution file (already filtered to test projects via ) - $testArgs += "--solution" - $testArgs += "Whizbang.slnx" + # Include ALL test projects (including integration tests) + # Use explicit DLL discovery instead of --solution to avoid picking up library projects like Whizbang.Testing + Ensure-BuildExists + # CRITICAL: Filter using Test-IsPrimaryTestDll to exclude copied DLLs from other projects' bin folders + $allTestDlls = @(Get-ChildItem -Path $repoRoot -Recurse -Filter "*.Tests.dll" -ErrorAction SilentlyContinue | + Where-Object { $_.FullName -match "bin[/\\]Debug[/\\]net10\.0[/\\]" } | + Where-Object { Test-IsPrimaryTestDll $_ } | + ForEach-Object { [System.IO.Path]::GetRelativePath($repoRoot, $_.FullName) }) + + if ($allTestDlls.Count -gt 0) { + $testArgs += "--test-modules" + $testArgs += ($allTestDlls -join ";") + + if (-not $useAiOutput) { + Write-Host "Discovered $($allTestDlls.Count) test projects (including integration tests)" -ForegroundColor Gray + } + } else { + Write-Warning "No test DLLs found after build. Check that test projects exist." + exit 1 + } } # Use --treenode-filter for test name filtering (MTP native filtering)