Skip to content

Commit bcba902

Browse files
committed
All tests pass
Full analysis of all test changes
1 parent 1b86b34 commit bcba902

File tree

5 files changed

+94
-30
lines changed

5 files changed

+94
-30
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ CrashLog.txt
178178
TestResults/
179179
*.trx
180180

181+
# WPF markup compilation temp projects
182+
*_wpftmp.csproj
183+
*_wpftmp.vbproj
184+
181185
# WiX v6
182186
*.wixpdb
183187

Src/FwCoreDlgs/FindCollectorEnv.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public class FindCollectorEnv : CollectorEnv, IDisposable
4444
/// <summary></summary>
4545
protected IVwSearchKiller m_searchKiller;
4646
/// <summary>
47-
/// True once we've reached the start location at least once during the current find.
48-
/// This allows us to apply the start offset across duplicate renderings of the same
49-
/// underlying string property (same hvo+tag but different cpropPrev).
47+
/// True once we've reached the start location during the current find.
48+
/// Once true, we should stop filtering objects (DisplayThisObject) so traversal
49+
/// can continue normally beyond the start point.
5050
/// </summary>
5151
private bool m_fReachedStartLocation;
5252
#endregion
@@ -112,17 +112,18 @@ public LocationInfo FindNext(LocationInfo startLocation)
112112

113113
private bool StartLocationAppliesToCurrentProp(int tag)
114114
{
115-
return m_StartLocation != null && m_StartLocation.TopLevelHvo == m_hvoCurr && m_StartLocation.m_tag == tag;
115+
// Apply the start offset only to the exact occurrence of the string property the
116+
// selection is in (tag + cpropPrev). Subsequent occurrences (different cpropPrev)
117+
// should search from the start of their own string.
118+
return m_StartLocation != null
119+
&& m_StartLocation.TopLevelHvo == m_hvoCurr
120+
&& m_StartLocation.m_tag == tag
121+
&& m_StartLocation.m_cpropPrev == CPropPrev(tag);
116122
}
117123

118124
/// <summary>
119125
/// Returns true if we should skip searching this property because we haven't reached the
120126
/// start location yet.
121-
///
122-
/// Once we have reached the start location, we keep <see cref="m_StartLocation"/> in
123-
/// place for any duplicate renderings of the same underlying string property (same hvo+tag),
124-
/// so they all respect the start offset and we don't re-find earlier matches in later
125-
/// duplicate instances.
126127
/// </summary>
127128
private bool ShouldSkipBecauseStartNotReached(int tag)
128129
{
@@ -164,7 +165,7 @@ private bool ShouldSkipBecauseStartNotReached(int tag)
164165
protected override bool DisplayThisObject(int hvoItem, int tag)
165166
{
166167
// We want to skip the beginning until we reach our start location.
167-
if (m_StartLocation == null || Finished)
168+
if (m_StartLocation == null || Finished || m_fReachedStartLocation)
168169
return true;
169170

170171
int cPropPrev = CPropPrev(tag);
@@ -223,8 +224,6 @@ public override void AddString(ITsString tss)
223224
// the tag that belongs to the open property. Some VCs output the contents of
224225
// a string property via AddString (e.g., around ORCs). We need to search those
225226
// strings too, not just AddStringProp/AddStringAltMember.
226-
CheckForStartLocationAndLimit(m_tagCurrent);
227-
228227
if (ShouldSkipBecauseStartNotReached(m_tagCurrent))
229228
return;
230229

@@ -440,7 +439,7 @@ protected virtual void DoFind(ITsString tss, int tag)
440439

441440
IVwTextSource textSource = m_textSourceInit as IVwTextSource;
442441
int ichBegin = 0;
443-
if (m_StartLocation != null)
442+
if (StartLocationAppliesToCurrentProp(tag))
444443
{
445444
Debug.Assert(m_StartLocation.TopLevelHvo == m_hvoCurr && m_StartLocation.m_tag == tag);
446445
ichBegin = m_StartLocation.m_ichLim;

TEST_CHANGE_LEDGER.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Range: `3c2e41b9..HEAD`
44

5+
Note: the working tree currently includes additional, uncommitted changes (not represented in the git range above). Those are called out inline where relevant.
6+
57
Purpose: An exhaustive ledger of every commit in-range that touched `**/*Tests.cs`, with a per-file classification:
68

79
- **Mechanical**: refactors/rewrites to keep tests compiling/running under new tooling (NUnit API changes, adapter-friendly asserts, mock framework swaps, formatting/cleanup) without materially changing what the test is trying to prove.
@@ -50,11 +52,16 @@ Supporting non-test `.cs` changes in this commit:
5052
- [B4] Src/Common/Controls/DetailControls/Slice.cs — **Substantive** — changes default expansion behavior so slices only auto-expand when explicitly marked `expansion="expanded"` (reduces UI-state surprises in tests).
5153
- [B1] Src/Common/FieldWorks/ProjectId.cs — **Substantive** — improves relative-path handling so paths with a directory component resolve under ProjectsDirectory without the “double nest” behavior.
5254
- [B2] Src/Common/SimpleRootSite/SimpleRootSite.cs — **Substantive** — best-effort unregisters `IVwNotifyChange` notifications during close/dispose to prevent post-dispose `PropChanged` callbacks destabilizing tests.
53-
- [B4] Src/FwCoreDlgs/FindCollectorEnv.cs — **Substantive** — fixes start-location semantics across duplicate renderings and captures WS at match offsets (stabilizes find/replace selection reconstruction).
55+
- [B4] Src/FwCoreDlgs/FindCollectorEnv.cs — **Substantive** — fixes start-location semantics across duplicate renderings, ensures the start offset applies only to the exact selected occurrence (tag + `cpropPrev`) including strings emitted via `AddString(...)`, and captures WS at match offsets (stabilizes find/replace selection reconstruction).
56+
57+
Working tree follow-up (uncommitted):
58+
59+
- [B4] Src/FwCoreDlgs/FindCollectorEnv.cs — **Substantive** — further refines start-location application to require an exact occurrence match and avoids clearing the start location prematurely in the `AddString(...)` path; resolves the remaining `FwFindReplaceDlgTests` failures under VSTest.
5460
- [B4] Src/FwCoreDlgs/FwFindReplaceDlg.cs — **Substantive** — TE-1658: WS-only replace behavior (empty Find text + Match WS) no longer advances incorrectly; adds selection restoration + WS propagation.
5561
- [B9] Src/xWorks/CssGenerator.cs — **Substantive** — avoids ExCSS crashes on `inherit` by using `none`/`unset` (and correct `UnitType.Ident`) to keep CSS generation deterministic.
5662
- [C2] Src/xWorks/DictionaryConfigManager.cs — **Substantive** — keeps rename operation defensive (revert/refresh on protected items) to match test expectations.
5763
- [D1] Build/Src/FwBuildTasks/RegFreeCreator.cs — **Mechanical** — fixes a node selection bug when adding/replacing CLR class entries in reg-free manifests.
64+
- [D1] test.ps1 — **Mechanical** — mitigates a VSTest multi-assembly edge case where `vstest.console.exe` returns exit code `-1` even when TRX reports 0 failures, by retrying per-assembly and aggregating exit codes; emits per-assembly TRX + console logs to aid isolation.
5865

5966
### 2025-12-17 — `44e740104481e4a0c2d9cdda2dc615931b4e9fbf` — Clear ignore fixes
6067

TEST_UPDATES_FROM_MODERNIZATION.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ For the complete classification of “baseline ignore was removed/reintroduced
7474
- In [TEST_CHANGE_LEDGER.md](TEST_CHANGE_LEDGER.md) under commit `65f81dc…`, WinForms-heavy fixtures (e.g., `StVcTests`, `FwFindReplaceDlgTests`) were moved toward STA and explicit layout/root creation.
7575
- In the same commit, the underlying find/replace implementation was adjusted (`FindCollectorEnv`, `FwFindReplaceDlg`) to make selection reconstruction and WS-only search/replace behavior more deterministic under isolation.
7676
- UI-state defaults that influence tests were also tightened (e.g., `Slice` expansion now only auto-expands when explicitly marked).
77-
- Note: several `FwFindReplaceDlgTests` still fail today; those are tracked in the TODO section below.
77+
- Follow-up: `FwFindReplaceDlgTests` are now passing under VSTest after refining `FindCollectorEnv` start-location semantics for the `AddString(...)` rendering path and ensuring the start offset only applies to the exact selected occurrence of the string property.
7878

7979
#### B5) ICU data discovery (ICU_DATA)
8080

@@ -147,6 +147,18 @@ For the complete classification of “baseline ignore was removed/reintroduced
147147
- Why this is treated as mechanical:
148148
- These changes generally don’t alter product behavior; they’re required to keep tests buildable/runnable and reporting correctly under the modern runner.
149149

150+
#### D1) VSTest multi-assembly exit code `-1` (false fail)
151+
152+
- What we observed:
153+
- A full-suite run that invoked `vstest.console.exe` with multiple test assemblies returned exit code `-1`, causing `test.ps1` to report `[FAIL] ... exit code: -1`.
154+
- The generated TRX indicated `failed="0"` (i.e., no failing tests), suggesting the exit code was unreliable for that scenario.
155+
- Why modernization surfaced it:
156+
- Moving from prior runners to VSTest changes process topology (testhost/execution isolation) and how failures are reported. In practice, “multi-assembly + VSTest” occasionally yields a non-specific `-1` even without test failures.
157+
- Fix rationale (root cause):
158+
- We treat the TRX/test results as the source of truth and make the orchestration resilient: when the multi-assembly invocation returns `-1`, `test.ps1` retries per assembly and aggregates exit codes.
159+
- This preserves strictness (real failures still fail the run) while avoiding false negatives caused by a runner edge case.
160+
- The per-assembly retry also produces actionable evidence: per-assembly TRX (`<AssemblyName>_<timestamp>.trx`) and per-assembly console logs (`vstest.<AssemblyName>.console.log`) in `Output\<Configuration>\TestResults`.
161+
150162
## Fishy / uncertain mappings (worth a quick human review)
151163

152164
Nothing here looks *obviously* off-scope for “stabilize tests under VSTest”, but these items do touch behavior enough that it’s reasonable to sanity-check intent:
@@ -171,21 +183,11 @@ Nothing here looks *obviously* off-scope for “stabilize tests under VSTest”,
171183

172184
## Current failing tests (TODO)
173185

174-
As of TRX: `Output\Debug\TestResults\johnm_SIL-XPS_2025-12-19_10_18_05.trx` (see `Output\Debug\TestResults\vstest.console.log`), the failing set is:
175-
176-
- `FwFindReplaceDlgTests.FindNextFromWithinMatchingWord` — selection verify mismatch (expected 1, was 0)
177-
- `FwFindReplaceDlgTests.FindNextWithMatch` — expected True, was False
178-
- `FwFindReplaceDlgTests.FindNextWithNoMatchAfterWrap` — expected True, was False
179-
- `FwFindReplaceDlgTests.FindWithMatchCase` — expected True, was False
180-
- `FwFindReplaceDlgTests.FindWithMatchDiacritics` — selection verify mismatch (expected 1, was 0)
181-
- `FwFindReplaceDlgTests.InitialFindPrevWithMatch` — selection verify mismatch (expected 2, was 0)
182-
- `FwFindReplaceDlgTests.InitialFindPrevWithMatchAfterWrap` — selection verify mismatch (expected 2, was 0)
183-
- `FwFindReplaceDlgTests.ReplaceTextAfterFootnote` — TsString mismatch (expected `BlaQlah!`, actual `Blah, blah, blah!`)
184-
- `FwFindReplaceDlgTests.ReplaceWithMatchWs_EmptyFindText` — selection verify mismatch (expected 3, was 7)
185-
186-
Suggested next debugging focus:
187-
- Re-check `DummyFwFindReplaceDlg.VerifySelection(...)` invariants under VSTest isolation.
188-
- Determine whether failure is caused by selection reconstruction, wrap state, or view initialization ordering in the dummy view.
186+
As of the most recent TRX in `Output\Debug\TestResults` (see `Output\Debug\TestResults\vstest.console.log`), there are no remaining failures in `FwFindReplaceDlgTests`.
187+
188+
Note: if a full-suite run ever reports `[FAIL] ... exit code: -1` while TRX shows 0 failures, `test.ps1` will retry per-assembly and the per-assembly TRX/logs should be used to confirm whether there are any real failures.
189+
190+
Baseline-ignored tests remain ignored (per branch policy).
189191

190192
## “No popups ever” plan (with external citations)
191193

test.ps1

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,58 @@ try {
460460
throw "Detected possible file is locked during vstest execution."
461461
}
462462
}
463+
464+
# =============================================================================
465+
# Workaround: multi-assembly VSTest may fail with exit code -1 and minimal output
466+
# =============================================================================
467+
468+
if (-not $ListTests -and $testDlls.Count -gt 1 -and $script:testExitCode -eq -1) {
469+
Write-Host "[WARN] vstest.console.exe returned exit code -1 with multiple test assemblies. Retrying per-assembly to isolate failures." -ForegroundColor Yellow
470+
471+
$timestamp = Get-Date -Format 'yyyyMMdd_HHmmss'
472+
$overallExitCode = 0
473+
474+
foreach ($testDll in $testDlls) {
475+
$dllName = [System.IO.Path]::GetFileNameWithoutExtension($testDll)
476+
Write-Host ""
477+
Write-Host "Running tests in $dllName..." -ForegroundColor Cyan
478+
479+
$singleArgs = @()
480+
$singleArgs += $testDll
481+
$singleArgs += "/Platform:x64"
482+
$singleArgs += "/Settings:$runSettingsPath"
483+
$singleArgs += "/ResultsDirectory:$resultsDir"
484+
$singleArgs += "/Logger:trx;LogFileName=${dllName}_${timestamp}.trx"
485+
$singleArgs += "/Logger:console;verbosity=$vstestVerbosity"
486+
487+
if ($TestFilter) {
488+
$singleArgs += "/TestCaseFilter:$TestFilter"
489+
}
490+
491+
$singleOutput = & $vstestPath $singleArgs 2>&1 | Tee-Object -Variable singleTestOutput
492+
$singleExitCode = $LASTEXITCODE
493+
if ($singleExitCode -ne 0 -and $overallExitCode -eq 0) {
494+
$overallExitCode = $singleExitCode
495+
}
496+
497+
$singleLogPath = Join-Path $resultsDir "vstest.${dllName}.console.log"
498+
try {
499+
$singleTestOutput | Out-File -FilePath $singleLogPath -Encoding UTF8
500+
}
501+
catch {
502+
Write-Host "[WARN] Failed to write VSTest output log to $singleLogPath" -ForegroundColor Yellow
503+
}
504+
505+
if ($singleExitCode -ne 0) {
506+
$singleOutputText = ($singleTestOutput | Out-String)
507+
if ($singleOutputText -match 'used by another process|file is locked|cannot access the file') {
508+
throw "Detected possible file is locked during vstest execution."
509+
}
510+
}
511+
}
512+
513+
$script:testExitCode = $overallExitCode
514+
}
463515
}
464516
}
465517
finally {

0 commit comments

Comments
 (0)