Skip to content

test(studio): the run slot and run state tested directly, and the results of a run in another workspace are not offered for export - #765

Merged
pbertsch merged 3 commits into
mainfrom
test/run-state
Nov 17, 2026
Merged

pbertsch merged 3 commits into
mainfrom
test/run-state

Conversation

@pbertsch

@pbertsch pbertsch commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

The run state machine is now tested directly (studio/run_slot_test.go), with -race: the run slot (claimRun, releaseRun, CancelRun, runActive) and the state a run leaves in RunState.

  • The slot moves free, claimed, cancelled, released: a second claim is refused and does not disturb the first; CancelRun stops the run's context but keeps the slot until the run ends, twice or with no run is harmless; a release frees it and stops the context; a new run is not born cancelled.
  • 64 concurrent starts: exactly one wins.
  • A run that cannot start (a scope that matches nothing, a path outside the folders) gives its slot back, and no connection is refused before the slot is taken.
  • Finish after cancel (real run on a blocked fake device): finished, no step in flight, the reason run cancelled, slot free; a late cancel changes nothing; the next run starts clean (no old error, results or finished flag).
  • Cancel while starting: the run ends as cancelled and leaves nothing to export.
  • Workspace changes mid-run (below).

Found and fixed

The results kept for Export were attributed to the workspace open when the run finished. Open another folder while a run goes and the finished run's results were offered for export there, with JUnit names relative to the wrong folder. executeRun now notes the workspace it started in and keepForExport keeps nothing when it is not the open one at the end. Re-opening the same workspace during a run keeps the results (a test).

Mutants

Eleven, all killed: claim does not refuse a second run, release keeps the slot, release does not stop the context (needed a test line; added), a run starts without a connection, a run that cannot start keeps the slot, finish leaves the current step, finish does not mark finished, finish drops the error, begin keeps the old state, a run of another workspace is kept, CancelRun does nothing.

"Lane results" has no Studio counterpart (Studio runs one device); the multi-device lanes are the CLI's and are tested there.

Test plan

  • go test -race on the new tests (count=3) and the export tests; mutants as above
  • disclosure scan

🤖 Generated with Claude Code

https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF

Review fixes

  • The workspace check and the keep are one step under a.mu, which SetWorkspace and useWorkspace also hold while they change the workspace and clear the export; a test forces the interleaving through a seam and a change that arrives between the two leaves nothing kept.
  • The run's workspace is taken with its slot (claimRun), not in executeRun after the path check; a test switches with useWorkspace after the claim.
  • Both the open and the starting workspace are compared in one spelling (cleaned, links resolved): a trailing slash, a dot segment or a link to the same folder is the same workspace (tests).
  • The report base held after a kept run is asserted. Mutants killed: compare and keep under separate locks, the raw spelling compared, SetWorkspace/useWorkspace not clearing the export, the run's workspace not recorded at claim, a wrong report base.

…ults of a run in another workspace are not offered for export

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch requested a review from a team as a code owner November 17, 2026 05:17
pbertsch and others added 2 commits November 16, 2026 23:49
…ace is taken with its slot, and one folder in two spellings is one workspace

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch merged commit 89aefe4 into main Nov 17, 2026
10 of 12 checks passed
jay23606 added a commit to jay23606/flutter-probe that referenced this pull request Nov 17, 2026
…ults of a run in another workspace are not offered for export (AlphaWaveSystems#765)

## Summary
The run state machine is now tested directly (`studio/run_slot_test.go`), with `-race`: the run slot (`claimRun`, `releaseRun`, `CancelRun`, `runActive`) and the state a run leaves in `RunState`.

- The slot moves free, claimed, cancelled, released: a second claim is refused and does not disturb the first; `CancelRun` stops the run's context but keeps the slot until the run ends, twice or with no run is harmless; a release frees it and stops the context; a new run is not born cancelled.
- 64 concurrent starts: exactly one wins.
- A run that cannot start (a scope that matches nothing, a path outside the folders) gives its slot back, and no connection is refused before the slot is taken.
- Finish after cancel (real run on a blocked fake device): finished, no step in flight, the reason `run cancelled`, slot free; a late cancel changes nothing; the next run starts clean (no old error, results or finished flag).
- Cancel while starting: the run ends as cancelled and leaves nothing to export.
- Workspace changes mid-run (below).

## Found and fixed
The results kept for Export were attributed to the workspace open **when the run finished**. Open another folder while a run goes and the finished run's results were offered for export there, with JUnit names relative to the wrong folder. `executeRun` now notes the workspace it started in and `keepForExport` keeps nothing when it is not the open one at the end. Re-opening the same workspace during a run keeps the results (a test).

## Mutants
Eleven, all killed: claim does not refuse a second run, release keeps the slot, release does not stop the context (needed a test line; added), a run starts without a connection, a run that cannot start keeps the slot, finish leaves the current step, finish does not mark finished, finish drops the error, begin keeps the old state, a run of another workspace is kept, CancelRun does nothing.

"Lane results" has no Studio counterpart (Studio runs one device); the multi-device lanes are the CLI's and are tested there.

## Test plan
- [x] `go test -race` on the new tests (count=3) and the export tests; mutants as above
- [x] disclosure scan



## Review fixes
- The workspace check and the keep are one step under `a.mu`, which `SetWorkspace` and `useWorkspace` also hold while they change the workspace and clear the export; a test forces the interleaving through a seam and a change that arrives between the two leaves nothing kept.
- The run's workspace is taken with its slot (`claimRun`), not in `executeRun` after the path check; a test switches with `useWorkspace` after the claim.
- Both the open and the starting workspace are compared in one spelling (cleaned, links resolved): a trailing slash, a dot segment or a link to the same folder is the same workspace (tests).
- The report base held after a kept run is asserted. Mutants killed: compare and keep under separate locks, the raw spelling compared, SetWorkspace/useWorkspace not clearing the export, the run's workspace not recorded at claim, a wrong report base.
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.

1 participant