gui: TestPrivacyModelFolder "back" step red once in a package run
internal/gui TestPrivacyModelFolder failed once in a package run at the head of eb8402c3d (v0.1.4821), on mote:
privacymodel_test.go:287: "back": Folder was still the picked folder, FolderSet false
It passes alone at origin/main and 10 of 10 at that head, and eb8402c3d doesn't touch the privacy model folder. Most likely an ordering or shared-state dependence on another test in the package (the "back" step reads a folder another test may have set). Not reproduced yet; inject a pause or run the package with -shuffle on to find it.
Reproduced this as a state-ordering race. privacyModelState loaded settings before checking the local model and read pii.MoveState() afterward. If a folder move completed during that work, the response could carry the completed moving:false state with the pre-move folder.
The patch reads the move state first, then reads the folder and olderSet from one settings snapshot after it. Clean patch branch against current main:
https://github.com/yetone/magpie/compare/main...L0NE-6:fix/7767-masking-folder-snapshot-upstream
Verification on Windows:
- the original test failed repeatedly before the change;
- go test ./internal/gui -run 'TestPrivacyModelFolder(UsesOneSnapshot)?$' -count=50 passes;
- the same test passes 10 race iterations;
- go vet ./internal/gui passes.
Taking this. CI's macos-latest 2/3 at de0d08317 (run 46206356942) shows the mixed state: Folder still the picked folder, FolderSet false, moving false. Checking the snapshot-ordering cause against the code and fixing it in privacyModelState. (L0NE-6, your compare link 404s now; the fork seems gone, so I'm writing the fix from your analysis.)
Fixed in e6cfc4335, released in v0.1.5065.
Cause: L0NE-6's analysis holds. privacyModelState read the folder (pii.Root), whether the user picked it (pii.Custom) and the move's state (pii.MoveState) one after another, each a separate read. moveModels saves the new folder and only then marks the move done. A move that saved and finished between those reads gave a response that said done (moving: false) with the old folder. CI's 2/3 output is that case: Folder still the picked folder, FolderSet false (the save landed between Root and Custom), Moving:false. It isn't only a test problem. Settings › Privacy polls only while moving is true, so a user could be left looking at the folder they had just moved away from, with the wrong Move back button, until they reopened the page.
Fix: the move's state is read first, then the folder and FolderSet come from the one settings.Load after it (pii.RootOf). A done read first means the settings read after already name the new folder.
TestPrivacyModelFolderStateIsOneMoment runs the move back from start to end at the moment the state reads the move's state (moveState seam). On the old code with only that seam swapped in, it fails on mote: done, with Folder:.../models FolderSet:true Moving:{Moving:false}. With the fix it passes. Also ran on mote: -race -count=20 on the folder tests, and ./internal/gui ./internal/pii ./internal/settings ./internal/masking at -timeout 45m, all ok. On mica, Linux and Windows go vet ./... passed.
L0NE-6, your compare link was 404 (the fork is gone), so this was written from your analysis, not your patch. Thanks for finding it.
I'm keeping this open until a CI run with the fix passes the macOS jobs.
CI Test run 46213062976 at e6cfc4335 (attempt 1): test (macos-latest, 2/3) passed, with internal/gui ok in 176.8s, TestPrivacyModelFolder and the new TestPrivacyModelFolderStateIsOneMoment included. macOS 3/3 and Windows passed too. macOS 1/3 and gateway were still running when I posted this. The run's one red is ubuntu's TestUpstreamNameReachesTheVendorOnly (internal/gateway). It is already open as #6487, was red the same way at de0d08317 before this fix, and has nothing to do with it. Closing as fixed in v0.1.5065.