Skip to content

test(live): static helpers stop doing console and file work themselves - #880

Merged
Blind-Striker merged 2 commits into
masterfrom
tests/852-static-live-helpers
Nov 15, 2026
Merged

Blind-Striker merged 2 commits into
masterfrom
tests/852-static-live-helpers

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

📝 Description

What does this PR do?
#852, the mixed option the maintainer chose. Background: coding-style.md says statics never perform outside-world work, and testing-style.md applies that to test code.

  • Category C (a static helper that calls a client, session or terminal it receives as an argument) stays as it is. testing-style.md gains one sentence: for the statics rule, a client, session, terminal or other seam that a test helper receives as an argument counts as an injected seam. The rule for direct console, file, clock, environment and process work is unchanged.
  • Category A (a static helper that wrote the console) and B (a static helper doing file work through a static RealFileSystem) are fixed in code. The re-check on the base found the issue's sites plus one more B:
Site Category Shape
PersistentPtyLiveTests: AssertSessionRemovalAsync, AssertSubmitHasNoTerminalAsync, AssertSubmittedLineRunsAsync, AssertDaemonAbsentArmsAsync, AssertRoundTripAsync A returns its evidence line through the row delegates and WithTerminalAsync; the three test methods print it
RpcClientLiveTests.WriteError → ErrorLine A formatter returns the line; the five calling tests print it
SessionPermissionLiveTests.WriteEvidence → EvidenceLine A formatter returns the line; the caller prints it
SessionMetadataLiveTests.CleanupAsync, SessionPermissionRulesLiveTests.CleanupAsync A returns the suppressed exception name or null; the instance finally prints it
SystemConfigurationIsolationLiveTests.SeedSystemDocumentAsync B instance member over an instance RealFileSystem _fileSystem (both #if NET arms kept)
OpenCodeServerStopLiveTests.Seed B instance member over _fileSystem
OpenCodeServerEnsureLiveTests.SeedAsync, ReadRegistrationAsync (the 4th B site, found on the base) B instance members over _fileSystem

The A sites take the second shape the decision names (a pure helper, with the caller keeping the I/O). The test classes have no injected console, and the analyzer wall (CA1822) refuses an instance member that touches no instance state. The B fields are typed RealFileSystem because CA1859 refuses IFileSystem for a field that only ever holds that type.

Related Issue(s):

🔄 Type of Change

  • 🧪 Test improvements
  • 📚 Documentation update

🎯 Protocol & API Surface

  • No change to the public API surface (tests and canon only)

🧪 Testing

  • No behaviour change. Every console line keeps its exact text, and still prints only after its helper's assertions have passed. Files are written with the same content. No assertion, expected value, test name or test count changed.

  • Proof: the existing rows pass, under the gate lock on Windows, net10.0, net11.0 and net48:

    • OpenCode.Sdk.Tests: 12619/12619;
    • OpenCode.Sdk.Tools.Tests except NativeAot: 2791/2791.
  • Proven by review, not by a run: four branches that no green run reaches.

    • The two CleanupAsync logging catches print only when cleanup fails after a primary failure.
    • The two daemon-absent PTY arms need a server without its terminal daemon.

    Their text and order were checked line by line.

  • Clone gate: 0 new. Two duplicates the baseline already held were only re-tokened. They map to their old fingerprints as quality-gates.md requires, proven by running the detector at the base:

New fingerprint Old fingerprint Before After
41876d574ec48db9 c045ab0efa440e92 PersistentPtyLiveTests 162–168 / 244–250 160–166 / 240–246
c3451242882eaa5c 7943699770a884f4 SessionMetadataLiveTests 108–119 / SessionPermissionRulesLiveTests 88–99 111–128 / 91–108

✅ Completion Gate

  • The local check passed on the pre-rebase tree. On the rebased head the build, both format passes and verify-clones pass; the test projects are being re-run there under the lock.

✅ Code Quality Checklist

  • No new suppressions; the baseline change is accounted for above
  • No tests skipped, weakened, or deleted

🔍 Additional Notes

  • Review. A fresh Opus reader reviewed the change in place of the usual Grok review (the Grok route is out of credits). No blocker or major. Three minors were fixed in the second commit: the stale <returns> docs, the Write* names that no longer write, and the _fileSystem field naming.
  • Recorded on Live test classes: static helpers do outside-world work the statics rule forbids #852, left out of this PR: Support/BranchReport.Print is a static console writer that live rows call. It sits outside the *LiveTests.cs scope the issue and this fix cover.

Closes #852 (the mixed option). testing-style.md gains one sentence:
for the statics rule, a seam a test helper receives as an argument counts
as an injected seam (category C; those helpers stay as they are).

Category A, the static helpers that wrote the console, now return what
they used to print, and the calling test method writes the same line:
PersistentPtyLiveTests' AssertSessionRemovalAsync,
AssertSubmitHasNoTerminalAsync, AssertSubmittedLineRunsAsync,
AssertDaemonAbsentArmsAsync and AssertRoundTripAsync (through the row
delegates and WithTerminalAsync); RpcClientLiveTests.WriteError and
SessionPermissionLiveTests.WriteEvidence (formatters returning the
line); the two CleanupAsync helpers in SessionMetadataLiveTests and
SessionPermissionRulesLiveTests (they return the observed exception name
or null).

Category B, the static helpers that did file work through a static
RealFileSystem, become instance members over an instance RealFileSystem
field: SystemConfigurationIsolationLiveTests.SeedSystemDocumentAsync,
OpenCodeServerStopLiveTests.Seed, and OpenCodeServerEnsureLiveTests'
SeedAsync and ReadRegistrationAsync. The field is typed RealFileSystem:
CA1859 refuses IFileSystem for a field that only holds that type.

Console lines, files, assertions and expected values are unchanged. Two
duplicates the baseline held were re-tokened and map to their old
fingerprints (quality-gates.md):

  41876d574ec48db9 <- c045ab0efa440e92  PersistentPtyLiveTests 162-168 / 244-250 -> 160-166 / 240-246
  c3451242882eaa5c <- 7943699770a884f4  SessionMetadataLiveTests 108-119 / SessionPermissionRulesLiveTests 88-99 -> 111-128 / 91-108
From the review of the #852 change: the two PTY helpers' <returns> docs
name the evidence line they now return; WriteError and WriteEvidence,
which no longer write, become ErrorLine and EvidenceLine; the three new
instance file-system fields follow the tests' _fileSystem convention.
Renames only; no behaviour change.
@Blind-Striker
Blind-Striker force-pushed the tests/852-static-live-helpers branch from 7328235 to e359590 Compare November 15, 2026 02:07
@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 15, 2026
Merged via the queue into master with commit 5ac86db Nov 15, 2026
15 checks passed
@Blind-Striker
Blind-Striker deleted the tests/852-static-live-helpers branch November 15, 2026 02:56
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.

Live test classes: static helpers do outside-world work the statics rule forbids

1 participant