You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(test): run a test suite and wait for it in one command (COR-15957) - #52
Adds --wait to vf test run create-suite, so one command runs every test, a set of tests or the tests in some folders, waits until every run has finished, and exits non-zero unless every run passed. Linear: COR-15957. The API side shipped in creator-app #24901, and the last regeneration added create-suite, wait-suite and test folder list.
What changes
--wait starts the suite, then waits for it in 45-second calls to the suite wait endpoint (the API caps one wait at 120 seconds) until every run has finished.
--max-wait caps the total wait, 30 minutes by default. When it runs out, the suite keeps running, and the error names the vf test run wait-suite command to keep waiting and the cancel command to stop the runs.
Output: progress on stderr (the bulkID when the suite starts, then a line like 1 of 4 passed, 1 failed, 2 still going whenever the counts change). The final wait result (counts, and the runs that did not pass with their failed checks) goes to stdout in whatever --output-format is set.
Exit code: 0 only when every run passed. 1 when a run failed or was canceled, or when --max-wait ran out. In agent mode those come as the usual error envelope, test_suite_failed or test_suite_unfinished, with hints, and progress comes as JSON events on stderr (started with the bulkID, waiting, retrying), like vf auth login, so all of stderr parses as JSON.
A wait that hits a 5xx, a 429, no answer or an answer cut off mid-body is retried up to 3 times, 5 seconds apart, so one dropped request does not end a long wait.
Once the suite has started, every failure names the wait-suite command that picks it up again, never "retry the command", which would start a second suite. An API error such as a 401 keeps its usual error_type, status_code and hints, and gets the resume command added. A failure after --max-wait has run out reports the last answer as unfinished. An answer that decodes to nothing stops the wait instead of being polled. Hints carry --server-url when it was passed, shell-quoted.
In agent mode, stderr is JSON from start to finish: anything not reported explicitly goes through one guard that renders it as the error envelope.
Each wait asks the API to hold for less when --timeout (flag, env or config) would otherwise cut the request off first.
--test-ids and --folder-ids also take comma-separated IDs, with or without --wait. They are generated as repeatable string arrays, so --test-ids a,b used to send the single ID "a,b" and get a 404.
IDs typed into the interactive prompt are split on commas too.
Before the suite starts (with --dry-run too), --wait checks --max-wait, refuses a --timeout under 10 seconds since no wait fits in it, and parses and compiles --jq, which would otherwise fail only after the whole wait.
Without --wait the generated command runs unchanged. --max-wait without --wait is refused.
--usage lists --wait and --max-wait, in vf --usage and every schema between it and create-suite --usage.
The token-format warning prints once per process rather than once per client, since --wait builds a client per wait so OAuth tokens refresh.
Logic lives in a new hand-written internal/cli/test/run/createsuite_wait.go. The generated createsuite.go gets one line (addCreateSuiteWait(cmd)), which wraps its RunE. The new hand-written internal/usage/extra_flags.go adds hand-written flags to the generated --usage schemas.
Unchanged: a flag value cobra cannot parse (--max-wait abc) still prints cobra's plain error, the same as for every vf command, before anything is sent.
The per-wait deadline is set on the context, because the generated operations.WithOperationTimeout checks for retry support instead of timeout support, so it refuses every operation without retries, WaitSuite included.
Tests
New test/run-suite-wait.test.ts (mock API), 22 tests. They cover:
Waiting through an unfinished answer and exiting 0; exiting 1 with the failed checks printed; --max-wait running out, with the keep-waiting hint.
Retries: a retried 502 and a retried cut-off answer. A 503 that outlasts the retries ends with the resume hint, not "retry the command". A failure after --max-wait reports the last answer.
Agent mode, where stderr has to be only JSON: progress events and the envelope; 401 and 404 keeping authentication_error / not_found plus the resume hint; an empty or null answer; a create answer with no bulkID; invalid flag values (--max-wait, --timeout, --jq); --wait --dry-run with a bad body.
Flags: --jq refused before start (syntax and unknown function); --wait checks under --dry-run; --usage at three levels; comma-separated --test-ids and --folder-ids.
These also catch a regeneration that drops the hook line.
New createsuite_wait_test.go: ID splitting, shell quoting of hint values, per-wait length within the API's 5 to 120 seconds and within --timeout, which errors are retried, the progress line.
gofmt -l . clean; go test ./... passes; behaviour tests (VF_SKIP_INTEGRATION_TESTS=1 yarn test): 127 passed; yarn oxlint: no new warnings.
An independent review traced every error return and stderr write in agent mode, with repros against a mock server. Its findings are fixed and covered above.
go vet ./... fails only on generated SDK files with unexported constant fields. It fails the same way on master (the Vet step is red on the last three master runs), and go vet is clean on the changed package.
Live against a dev env: a folder suite (1 run) and two tests passed as --test-ids a,b, both with --wait. Both finished in under 35 seconds and exited 0.
Not run: speakeasy run, to re-check that the hook line survives regeneration. The behaviour tests fail if it does not.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved deadline and timeout handling can exceed --max-wait, falsely report success, or leave queued runs behind, while unnormalized interactive IDs can cause invalid requests.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Agent-mode stderr includes human-readable output that breaks JSON consumers, and truncated responses are not retried, prematurely ending waits for running suites.
A connection dropped after response headers is not retried: WaitSuite propagates a wrapped io.ErrUnexpectedEOF from ConsumeRawBody, which this classifier rejects. A single truncated response—including a 502—therefore ends the wait while the suite keeps running. Import io and net, extend the classifier to recognize io.ErrUnexpectedEOF and net.Error, and cover a truncated response in the mock tests.
Also from the review overview ("previously missed"): a wait whose answer was cut off mid-body (io.ErrUnexpectedEOF from reading the body) is now retried, as is any net.Error. Fixed in fd89c71, with a Go case and a mock test that sends headers and half a body, then drops the connection.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Long-running suite monitoring can stop when OAuth tokens expire, and several agent-mode flag validation errors return plain text instead of the expected JSON error envelope.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Return validation errors in the agent JSON envelope
internal/cli/test/run/createsuite_wait.go:102
In agent mode, --max-wait without --wait returns plain text, so parsing stderr as JSON fails. The same issue affects nonpositive --max-wait values at line 159 and a too-short --timeout at lines 168–169. Route all three validation errors through suiteError with invalid_flag_value so they produce the usual error envelope.
Refresh OAuth credentials before each wait
internal/cli/test/run/createsuite_wait.go:255
The SDK resolves OAuth credentials only when client.NewClient runs, so this loop keeps sending the original access token. If that token expires during a long suite, the next wait returns a non-retryable 401 and monitoring stops despite an available refresh token. Rebuild the configured client before each wait so oauth.AccessToken can refresh while preserving flag/environment token overrides.
Both "previously missed" issues from the latest review are fixed in 00b4d3a:
Validation errors in agent mode:--max-wait without --wait, a --max-wait of zero or less, and a --timeout under 10s now go through suiteError as invalid_flag_value (the type flagerrors.go uses), each with a hint. In agent mode they come as the usual envelope. A new behaviour test checks that each produces exactly one JSON envelope on stderr and sends no request.
OAuth refresh during a long wait: the loop now builds the client before each wait, which is when credentials are resolved. An OAuth access token that expires mid-suite is refreshed, as it is for any vf command, while --token and VF_TOKEN still win. Checked live against a dev env.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Some wait failures bypass the agent-mode error renderer, causing prose to appear in stderr after JSON progress events; these errors need structured rendering and regression coverage.
…mable (COR-15957)
- Every failure in agent mode reaches stderr as a JSON envelope, after the
progress events; anything not reported explicitly is caught by one guard.
- After the suite starts, failures say how to keep waiting (wait-suite)
instead of to rerun, which would start a second suite. API errors keep
their error_type, status_code and hints.
- A wait answer that decodes to nothing stops instead of being polled until
--max-wait; a failure after --max-wait reports the last answer.
- --max-wait, --timeout and --jq (parsed and compiled) are checked before the
suite starts, under --dry-run too.
- Hints carry --server-url and are shell-quoted; the token warning prints
once per process; --usage lists --wait and --max-wait at every level.
Co-authored-by: Cursor <cursoragent@cursor.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human review is needed to assess JSON-output violations, duplicate-suite risks after ambiguous creation failures, and expired deadlines from non-positive configured timeouts.
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
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.
Adds
--waittovf test run create-suite, so one command runs every test, a set of tests or the tests in some folders, waits until every run has finished, and exits non-zero unless every run passed. Linear: COR-15957. The API side shipped in creator-app #24901, and the last regeneration addedcreate-suite,wait-suiteandtest folder list.What changes
--waitstarts the suite, then waits for it in 45-second calls to the suite wait endpoint (the API caps one wait at 120 seconds) until every run has finished.--max-waitcaps the total wait, 30 minutes by default. When it runs out, the suite keeps running, and the error names thevf test run wait-suitecommand to keep waiting and thecancelcommand to stop the runs.bulkIDwhen the suite starts, then a line like1 of 4 passed, 1 failed, 2 still goingwhenever the counts change). The final wait result (counts, and the runs that did not pass with their failed checks) goes to stdout in whatever--output-formatis set.--max-waitran out. In agent mode those come as the usual error envelope,test_suite_failedortest_suite_unfinished, with hints, and progress comes as JSON events on stderr (startedwith thebulkID,waiting,retrying), likevf auth login, so all of stderr parses as JSON.wait-suitecommand that picks it up again, never "retry the command", which would start a second suite. An API error such as a 401 keeps its usualerror_type,status_codeand hints, and gets the resume command added. A failure after--max-waithas run out reports the last answer as unfinished. An answer that decodes to nothing stops the wait instead of being polled. Hints carry--server-urlwhen it was passed, shell-quoted.--timeout(flag, env or config) would otherwise cut the request off first.--test-idsand--folder-idsalso take comma-separated IDs, with or without--wait. They are generated as repeatable string arrays, so--test-ids a,bused to send the single ID"a,b"and get a 404.--dry-runtoo),--waitchecks--max-wait, refuses a--timeoutunder 10 seconds since no wait fits in it, and parses and compiles--jq, which would otherwise fail only after the whole wait.--waitthe generated command runs unchanged.--max-waitwithout--waitis refused.--usagelists--waitand--max-wait, invf --usageand every schema between it andcreate-suite --usage.--waitbuilds a client per wait so OAuth tokens refresh.Logic lives in a new hand-written
internal/cli/test/run/createsuite_wait.go. The generatedcreatesuite.gogets one line (addCreateSuiteWait(cmd)), which wraps itsRunE. The new hand-writteninternal/usage/extra_flags.goadds hand-written flags to the generated--usageschemas.Unchanged: a flag value cobra cannot parse (
--max-wait abc) still prints cobra's plain error, the same as for every vf command, before anything is sent.The per-wait deadline is set on the context, because the generated
operations.WithOperationTimeoutchecks for retry support instead of timeout support, so it refuses every operation without retries,WaitSuiteincluded.Tests
test/run-suite-wait.test.ts(mock API), 22 tests. They cover:--max-waitrunning out, with the keep-waiting hint.--max-waitreports the last answer.authentication_error/not_foundplus the resume hint; an empty ornullanswer; a create answer with nobulkID; invalid flag values (--max-wait,--timeout,--jq);--wait --dry-runwith a bad body.--jqrefused before start (syntax and unknown function);--waitchecks under--dry-run;--usageat three levels; comma-separated--test-idsand--folder-ids.createsuite_wait_test.go: ID splitting, shell quoting of hint values, per-wait length within the API's 5 to 120 seconds and within--timeout, which errors are retried, the progress line.gofmt -l .clean;go test ./...passes; behaviour tests (VF_SKIP_INTEGRATION_TESTS=1 yarn test): 127 passed;yarn oxlint: no new warnings.go vet ./...fails only on generated SDK files with unexported constant fields. It fails the same way on master (theVetstep is red on the last three master runs), andgo vetis clean on the changed package.--test-ids a,b, both with--wait. Both finished in under 35 seconds and exited 0.speakeasy run, to re-check that the hook line survives regeneration. The behaviour tests fail if it does not.