Test hygiene: no CDP port in unit-test WebView2s; reset Program statics#8076
Merged
Conversation
Contributor
|
| Filename | Overview |
|---|---|
| src/BloomExe/WebView2Browser.cs | Adds !Program.RunningUnitTests guard so CDP debugging port is never requested when running in a test process, preventing port-collision failures on CI machines. |
| src/BloomTests/ProgramTests.cs | Adds a [TearDown] that re-parses empty args to reset all Program statics after each test, preventing StartupAutomation=true from leaking into later fixtures. |
| src/BloomTests/ShellTests.cs | Adds the same [TearDown] reset pattern as ProgramTests, guarding against static state leak from its own --automation call. |
Reviews (3): Last reviewed commit: "Test hygiene: no CDP port in unit-test W..." | Re-trigger Greptile
Contributor
Author
|
[Claude/Fable] Consulted Devin on 2026-07-17 up to commit 47cd1f2 — review clean (0 bugs, 0 flags). |
Two issues found while investigating CI failures in the upload
integration tests (whose actual cause is server-side: the bloomlibrary
API's upload-start endpoint intermittently returns a bare 500 for
env=unit-test — reproducible with curl, nothing to do with client
code):
- WebView2Browser passed --remote-debugging-port (BloomServer http
port + 2) to every WebView2 whenever a BloomServer was listening in
the process, including in unit tests. Nothing attaches to a test-run
WebView2, and on a CI machine that also runs real Bloom instances
the port can already be taken, which breaks WebView2 startup and
fails whatever test needed the browser. Now skipped when running
unit tests.
- ProgramTests and ShellTests called
Program.ParseStartupPortArguments("--automation") and left
StartupAutomation=true in the Program statics for every later
fixture in the run, making BloomServer print BLOOM_AUTOMATION_READY
banners in unrelated tests' output. Both fixtures now re-parse empty
args in a TearDown, which resets all the startup statics.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
andrew-polk
force-pushed
the
dontExposeCdpPortInUnitTests
branch
from
July 17, 2026 17:12
47cd1f2 to
3a4f158
Compare
andrew-polk
marked this pull request as ready for review
July 17, 2026 17:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two test-hygiene fixes found while investigating CI failures in the upload integration tests. (The actual cause of those CI failures is server-side —
POST https://api.bloomlibrary.org/v1/books/new:upload-start?env=unit-testcurrently returns a bare 500, reproducible with curl — so this PR does not fix them; it fixes two real hazards the investigation surfaced.)Don't request a CDP port for unit-test WebView2s.
WebView2Browserpassed--remote-debugging-port=<BloomServer http port + 2>to every WebView2 whenever a BloomServer was listening in the process — including unit tests. Nothing ever attaches to a test-run WebView2, and on a CI machine that also runs real Bloom instances the port can already be taken, which breaks WebView2 startup and fails whatever test needed the browser. Now skipped whenProgram.RunningUnitTests.ProgramTestsno longer leaksStartupAutomation=true. ItsParseStartupPortArguments("--automation", …)tests left the Program statics set for every later fixture in the run, which madeBloomServerprintBLOOM_AUTOMATION_READYbanners in unrelated tests' output (and would defeat fix Modify .gitignore file #1's gate-adjacent reasoning about automation state). ATearDownnow re-parses empty args, which resets all the startup statics.🤖 Generated with Claude Code
Devin review
This change is