Repository navigation
LT-22840: Stop tests rewriting shared registry paths; add opt-in repair - #1183
Conversation
NUnit Tests 1 files ± 0 1 suites ±0 14m 10s ⏱️ -57s Results for commit 5dcdce8. ± Comparison against base commit 936ae91. This pull request removes 2 and adds 105 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1183 +/- ##
==========================================
+ Coverage 39.88% 40.52% +0.63%
==========================================
Files 1542 1559 +17
Lines 355361 356080 +719
Branches 41320 41586 +266
==========================================
+ Hits 141753 144292 +2539
+ Misses 184253 182477 -1776
+ Partials 29355 29311 -44
🚀 New features to boost your workflow:
|
|
Update: removed the unused |
c9bf157 to
19d5858
Compare
jasonleenaylor
left a comment
There was a problem hiding this comment.
The HKCU override is deliberate. Per-user RootCodeDir, RootDataDir and ProjectsDir values let a user redirect an installation without touching HKLM, and that capability was designed specifically for FieldWorks in grad lab courses and for user support. Developer machines use the same mechanism on purpose (see the note at FieldWorks.cs:3574), and installing a release on a developer machine has never been a supported setup. I don't want the installed readers changed to accommodate that setup.
The testing that found this doesn't need code changes. To check LT-22836 against 9.3.10, any of these keeps the installed build away from your dev keys:
- Windows Sandbox or a VM, where HKCU starts clean
- a second local Windows account, since HKCU is per user
reg exporttheFieldWorks\9key, remove the values, test, thenreg import- a dev build of the
release/9.3.10branch, which uses its ownDistFilessince #1093
LT-22840 notes that the reader change can't fix the installed 9.3.10 anyway, so that machine needs the cleanup either way.
The reader changes also break cases the override serves:
ParatextLexiconPluginDirectoryFinderhas no dev-tree detection, so a plugin loaded by Paratext now ignores an HKCURootCodeDirthat points at a source tree.- Native
DirectoryFinder::FwRootDataDirinUtil.cppstill reads HKCU first, so managed and native code would disagree on the data directory. - In a dev run, Project Location with "move" moves every project out of the HKCU
ProjectsDir, but the new path lives only in memory. The next launch, dev or installed, finds an empty folder.
Please drop the reader filters and the ProjectsDirectory change, and keep the mkall.targets registry targets until someone runs the new-machine setup test that Hasso's note asks for. A smaller PR with the read-only Resolve-FieldWorksDevRegistry.ps1, the InitializeIcu fix for a missing ICU folder, and the test initializer change would be welcome. The repair script can go with it as an opt-in tool, but it should leave SilEncConverters40\DeveloperPluginDir alone.
This review was assisted by Claude Opus 5.5.
19d5858 to
a8e013b
Compare
|
Shrunk as you asked. The branch is now three commits on the original base:
Dropped: the installed-reader filters, the Paratext finder change and the On Windows: the build passes; |
jasonleenaylor
left a comment
There was a problem hiding this comment.
Thanks for taking the redesign; this is the shape I was hoping for. Two nits, neither blocking.
Please retitle before merging. The squash merge commit needs to describe the work that is actually committed: a subject in line with the title, and a body that is a very brief version of the PR description. The current title describes the reader filters that were dropped. Something like "Stop tests from rewriting shared registry paths; add an opt-in repair" fits what is here.
This review was assisted by Claude Opus 5.5.
| try | ||
| { | ||
| if (withUserOverride) | ||
| userKey.SetValue(valueName, "InstalledDirectory"); |
There was a problem hiding this comment.
Nit: this writes the real HKCU FieldWorks\9 key. The finally covers a failed assertion, but a test run killed between here and the restore leaves RootCodeDir set to InstalledDirectory, which is the shared-registry damage this PR guards against. Swapping in a dummy IFwRegistryHelper over a scratch subkey with FwRegistryHelper.Manager.SetRegistryHelper (as MainWindowDelegateTests does) would keep the test off the shared key.
There was a problem hiding this comment.
The fixture already swaps in DummyFwRegistryHelper in [OneTimeSetUp] (line 38), so FieldWorksRegistryKey here is the scratch HKCU\Software\SIL\FieldWorks\UnitTests\9, not the real FieldWorks\9. 5dcdce8 adds an assertion that the key is under UnitTests before any write, so the test fails instead of touching the shared key if that setup ever changes.
The fixture already swaps in DummyFwRegistryHelper, so the override test writes to HKCU\Software\SIL\FieldWorks\UnitTests\9, not the shared FieldWorks\9 key. Assert that before any write so the test fails rather than touching the shared key if the swap is ever lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Start here:
Build/Repair-DeveloperRegistry.ps1previews and, on request, removes source-tree overrides from the current user's registry.The launch preflight is read-only, including with
-Force. An opt-in repair can remove identified worktree code, data, ICU, encoding-converter root andsilfw://overrides. Test initialization no longer overwrites shared code and data paths, and ICU initialization skips registry paths that do not exist.HKCU overrides remain deliberate: installed and Paratext readers retain their existing precedence, and a projects-folder change still persists. The repair keeps
ProjectsDirandSilEncConverters40\DeveloperPluginDir; inspect-WhatIfbefore applying it. The build's registry targets remain available pending new-machine setup verification.Where to look
Repair-DeveloperRegistry.Tests.ps1: selective cleanup, preview and preserved values.InitializeFwRegistryHelperAttributeandFwDirectoryFinderTests: test setup does not rewrite shared directory values.FwUtils.ChooseIcuDataDirandIcuDataDirChoiceTests: an existing user ICU directory wins; otherwise try the machine value.Not here: no installed-reader source-tree filters, Paratext or Convert changes, or changes to
ProjectsDirectory. The repair cannot identify a checkout whoseFieldWorks.slnhas moved or been removed.Verification (Windows/x64, at
a8e013bef):.\build.ps1 -CommentHygiene -TokenHygiene: passed.Repair-DeveloperRegistry.Tests.ps1: 23 checks passed in Windows PowerShell 5.1 and PowerShell 7.FwUtilsTests: 489 of 493 passed. The 4 failures areDebugProcsTests.GetMessage_*(\nagainst\r\n). That file is unchanged from the base, and the same tests pass on the base in a CRLF checkout; the failing run used an LF checkout.test.ps1, and a manual Project Location move and relaunch.Next: review the cleanup scope.
Registry behavior
ICU_DATAstill wins when set. Otherwise an existing HKCU ICU directory wins over an existing HKLM directory, followed by the existing development-tree fallback. A nonexistent per-user path is skipped in favor of an existing machine path. Explicit repair can also remove source-tree encoding-converter repository andsilfw://values; it preserves values outside identified worktrees.This change is