Skip to content

test: refactor runCliSync to unify cli tests#1458

Merged
Timeless0911 merged 2 commits intomainfrom
refactor/test-run-cli-sync
Jan 28, 2026
Merged

test: refactor runCliSync to unify cli tests#1458
Timeless0911 merged 2 commits intomainfrom
refactor/test-run-cli-sync

Conversation

@Timeless0911
Copy link
Copy Markdown
Contributor

@Timeless0911 Timeless0911 commented Jan 28, 2026

Summary

  • Refactor runCliSync in tests/scripts/shared.ts to use spawnSync instead of execSync. This allows for better handling of stdout/stderr and exit codes in tests. Updated integration tests to match the new return signature.

  • do not use shell: true to prevent (node:33665) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 28, 2026 08:44
@Timeless0911 Timeless0911 changed the title test: refactor runCliSync to use spawnSync test: refactor runCliSync to unify cli tests Jan 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the runCliSync function in the test utilities to use spawnSync instead of execSync, improving the handling of stdout, stderr, and exit codes in tests. The function now returns a structured object with status, stdout, and stderr properties instead of just a string.

Changes:

  • Refactored runCliSync to use spawnSync for better control over process execution and output handling
  • Updated function signature to accept both string and array command formats, returning an object with exit status and cleaned output streams
  • Updated 11 integration test files to destructure the new return format and remove error-based control flow in favor of status code checking

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/scripts/shared.ts Replaced execSync with spawnSync, changed return type to object with status/stdout/stderr, added stripAnsi for output cleaning
tests/integration/dts/composite/index.test.ts Updated to use runCliSync and destructure status from return value
tests/integration/dts/bundle/index.test.ts Updated to use runCliSync and destructure status from return value
tests/integration/dts/bundle-false/index.test.ts Updated to use runCliSync and destructure status from return value
tests/integration/dts/build/index.test.ts Updated to use runCliSync and destructure status/stderr from return value
tests/integration/dts-tsgo/bundle/index.test.ts Updated to use runCliSync and destructure status from return value
tests/integration/dts-tsgo/bundle-false/index.test.ts Updated to use runCliSync and destructure status from return value
tests/integration/dts-tsgo/build/index.test.ts Updated to use runCliSync and destructure status from return value
tests/integration/cli/unknown-option/index.test.ts Replaced try-catch error handling with direct status code checking
tests/integration/cli/mf/mf.test.ts Replaced try-catch error handling with direct status code checking and removed unnecessary stripAnsi import
tests/integration/cli/log-level/index.test.ts Updated to destructure stdout from return value and removed stripAnsi import
tests/integration/cli/build/build.test.ts Updated config file not found test to check status/stderr; changed build options test to use array format for complex arguments

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Timeless0911 Timeless0911 merged commit 221c66b into main Jan 28, 2026
12 checks passed
@Timeless0911 Timeless0911 deleted the refactor/test-run-cli-sync branch January 28, 2026 11:03
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.

2 participants