Skip to content

test(oxfmt): Add oxfmt --lsp test#16866

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-15-test_oxfmt_add_oxfmt_--lsp_test
Dec 15, 2025
Merged

test(oxfmt): Add oxfmt --lsp test#16866
graphite-app[bot] merged 1 commit intomainfrom
12-15-test_oxfmt_add_oxfmt_--lsp_test

Conversation

@leaysgur
Copy link
Copy Markdown
Member

@leaysgur leaysgur commented Dec 15, 2025

Just adding test, but it requires to update test utils.

@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Dec 15, 2025
Copy link
Copy Markdown
Member Author

leaysgur commented Dec 15, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new --lsp test is likely flaky because it closes stdin immediately and only asserts on substring matches rather than decoding a complete LSP frame and validating the JSON-RPC response. Additionally, runCli() now enforces a timeout: 1000, which is prone to CI intermittency and may cause random failures for slower startup paths. Tightening the test to read/parse a full response and making the timeout configurable would significantly improve reliability.

Summary of changes

What changed

  • Added a new Vitest test apps/oxfmt/test/lsp.test.ts that starts oxfmt with --lsp, sends a JSON-RPC initialize request over stdin, and asserts the process exits successfully and returns an LSP-ish response (e.g., Content-Length: and "capabilities").
  • Refactored apps/oxfmt/test/utils.ts:
    • Introduced a shared runCli(cwd, args) helper that returns the raw execa() result (with reject: false and a timeout: 1000).
    • Removed the custom RunResult wrapper type and mapping.
    • Updated formatSnapshot() to accept execa’s Result type and normalize exitCode/stdout/stderr (exitCode ?? -1, String(stdout), String(stderr)).

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 15, 2025 02:01
@leaysgur leaysgur force-pushed the 12-15-test_oxfmt_add_oxfmt_--lsp_test branch from 3444300 to 1289271 Compare December 15, 2025 02:14
@leaysgur leaysgur force-pushed the 12-15-test_oxfmt_update_oxfmt_--init_migrate_tests branch from 203ffa2 to a9148bd Compare December 15, 2025 02:14
@leaysgur leaysgur force-pushed the 12-15-test_oxfmt_add_oxfmt_--lsp_test branch from 1289271 to e8e305f Compare December 15, 2025 02:19
@leaysgur leaysgur requested a review from Dunqing December 15, 2025 02:26
@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
Copy link
Copy Markdown
Member

Dunqing commented Dec 15, 2025

Merge activity

Just adding test, but it requires to update test utils.
@graphite-app graphite-app bot force-pushed the 12-15-test_oxfmt_update_oxfmt_--init_migrate_tests branch from a9148bd to 3dcb523 Compare December 15, 2025 02:50
@graphite-app graphite-app bot force-pushed the 12-15-test_oxfmt_add_oxfmt_--lsp_test branch from e8e305f to 1d9e0f4 Compare December 15, 2025 02:51
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
Base automatically changed from 12-15-test_oxfmt_update_oxfmt_--init_migrate_tests to main December 15, 2025 02:57
@graphite-app graphite-app bot merged commit 1d9e0f4 into main Dec 15, 2025
19 checks passed
@graphite-app graphite-app bot deleted the 12-15-test_oxfmt_add_oxfmt_--lsp_test branch December 15, 2025 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants