Skip to content

test: a view model's InitializationComplete is its newest load, so a test waits for the one still running - #2948

Merged
laurentiu021 merged 1 commit into
mainfrom
test/initialization-complete-is-the-newest-load
Oct 22, 2026
Merged

laurentiu021 merged 1 commit into
mainfrom
test/initialization-complete-is-the-newest-load

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

ViewModelBase.InitializeAsync set InitializationComplete to the task RunInitAsync returned, and by then
RunInitAsync had already run the load to its first await. A load that resumed on another thread in that window, as
one does when no dispatcher queues it, which is how the unit tests run, could start a second load through
InitializeAsync first, and the older task then replaced the newer one. A test awaiting the property went on while
the newer load was still running.

DisplayProfileViewModelTests.AWindowsDisplayChange_ReadsTheDisplaysAgain_AndLeavesTheStatusLineAlone failed that way
on #2945's first CI run: reading the displays selects one, which starts reading its modes, and the test's wait ended
before they were read, so Keep said "Display set to ." with no mode in it.

What changed

  • The property is set before the load starts: InitializeAsync builds the load as an unstarted task, sets the
    property to it, and runs it in place on the calling thread, as the direct call did. A load started later sets the
    property later.
  • Behaviour in the app is unchanged. The tabs that read the property in the app (to refresh on being shown once
    their first load is done) start one load each. The two tabs that start a load from another, Display Profiles and
    Bulk Installer, start it after an await or on a change the user makes.

Tests

  • ViewModelBaseTests.InitializationComplete_IsTheNewestLoad_WhenItStartedBeforeTheFirstReturned: a load that starts
    a second one on another thread before its own call returns. Before the change the property was the first load's
    task, already finished; it is now the second's, still running until the test completes it.
  • The 1,822 tests in the 52 unit classes that await a view model's load pass with the change, as do the base class's
    fault tests, which await the property for what a load threw.

Closes #2947.

…test waits for the one still running

- InitializeAsync set InitializationComplete to the task RunInitAsync returned, once RunInitAsync had already run the
  load to its first await. A load that resumed on another thread in that window, as one does when no dispatcher
  queues it, which is how the unit tests run, could start a second load first, and the older task then replaced the
  newer one. A Display Profiles test failed that way on CI: its wait ended before the selected display's modes were
  read (#2947).
- The property is now set before the load starts, from an unstarted task run in place, so a load started later sets
  it later.
- Behaviour in the app is unchanged. The tabs that read the property start one load each, and the two that start a
  load from another, Display Profiles and Bulk Installer, start it after an await or on a change the user makes.
// does when no dispatcher queues it, can start a second load before then, and setting the property afterwards
// replaced that newer load's task with this older one, so whoever awaited it went on while the newer load was
// still running (#2947).
var start = new Task<Task>(() => RunInitAsync(asyncAction, callerName));
@laurentiu021
laurentiu021 merged commit f193da1 into main Oct 22, 2026
6 checks passed
@laurentiu021
laurentiu021 deleted the test/initialization-complete-is-the-newest-load branch October 22, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cross-app — InitializationComplete can hold an older load than the one running, so a test stops waiting too early

2 participants