Test: stop swallowing the parse error in the cloud_run pass-through CLI test - #709
Open
AmaadMartin wants to merge 1 commit into
Open
Test: stop swallowing the parse error in the cloud_run pass-through CLI test#709AmaadMartin wants to merge 1 commit into
AmaadMartin wants to merge 1 commit into
Conversation
…LI test The exercise step wrapped `await parse(args)` in a try/catch whose only body was `console.log(e)`. That violates the no-console rule for tests, and it replaces an accurate failure with a misleading one: the caught error goes to stdout and the test then dies on the next line with `TypeError: Cannot read properties of undefined (reading '0')`. Let the error propagate, like the other 25 parse call sites in the file.
This was referenced Aug 8, 2026
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
N/A
Problem: In
dev/test/cli/cli_test.ts, the testshould pass args to deployToCloudRun including unknownswrapped its exercise step intry { await parse(args); } catch (e) { console.log(e); }. A test file must not write to stdout. The catch also degrades the failure signal: it prints the real error and lets execution reach the next line, wheremock.calls[0]isundefined, so the test dies onTypeError: Cannot read properties of undefined (reading '0').Solution: I deleted the try/catch and call
await parse(args)bare, like the other 25parsecall sites in the file. The localparsehelper (lines 65-74) already absorbs the expectedcommander.exit, so anything it re-throws is a genuine failure that must fail the test at its own call site. The catch was unreachable on a passing run:cloud_runsets.allowUnknownOption()and.allowExcessArguments()so commander accepts this argv, and the action body catches its own errors whiledeployToCloudRunis module-mocked. The sibling clean-up incli_deploy_agent_engine_test.tsis out of scope here because it is already up for review onfix/remove-debug-scaffolding-cli-deploy-agent-engine-test.Collision check: I listed all open PRs on the fork and diffed the five that touch
dev/test/cli/cli_test.ts(#694, #693, #587, #455, #447). None removes thisconsole.log, and no hunk of theirs overlaps lines 303-307.Testing Plan
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
npx vitest run --project unit:dev dev/test/cli/cli_test.tsreports 26 passed, with nostdout |block attributed to the file.npx vitest run --project unit:dev dev/test/cli/cli_deploy_agent_engine_test.tsreports 18 passed and still prints its own debug lines, which confirms I left that file alone.No test is added. The change removes four lines of test scaffolding and adds no production code, so coverage cannot move:
vitest.config.tsmeasurescore/src,dev/srcandintegrations/srconly.Mutation proof. I made the
parsehelper reject for this test's argv withif (args.includes('--extra-arg=foo')) throw new Error('mutation probe');and ran the suite twice.Before the fix, the error goes to stdout and the reported failure is wrong:
After the fix, the reported failure is the real error and stdout is empty:
I then removed the probe and re-ran: 26 passed.
Manual End-to-End (E2E) Tests:
Not applicable. No user-visible behaviour changes and no production code is touched.
Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.