Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 30, 2025

This PR adds comprehensive unit test coverage for the execUtils.ts utility functions that handle argument quoting for command execution.

Overview

The execUtils.ts module contains two utility functions used throughout the extension:

  • quoteStringIfNecessary(arg: string): Adds quotes around strings containing spaces (unless already quoted)
  • quoteArgs(args: string[]): Maps the quoting function over an array of arguments

These functions are critical for properly escaping command-line arguments, especially on Windows where paths often contain spaces (e.g., C:\Program Files\Python).

Test Coverage Added

Created src/test/features/execution/execUtils.unit.test.ts with 25 comprehensive tests:

quoteStringIfNecessary tests (15 tests):

  • ✅ Strings without spaces remain unquoted
  • ✅ Strings with spaces get properly quoted
  • ✅ Already-quoted strings are not double-quoted
  • ✅ Edge cases: empty strings, only spaces, leading/trailing spaces
  • ✅ Partial quote handling (strings with quotes on one side only)
  • ✅ Special characters and path separators

quoteArgs tests (10 tests):

  • ✅ Empty array handling
  • ✅ Mixed quoted and unquoted arguments
  • ✅ Command-line flag patterns (--flag "value with spaces")
  • ✅ Windows and Unix path handling
  • ✅ Argument order preservation

Testing Approach

Following the repository's testing workflow instructions:

  • Used *.unit.test.ts naming convention for fast, isolated testing
  • No mocking required (pure utility functions)
  • Clear test names describing expected behavior
  • Simple arrange-act-assert structure for maintainability

Verification

All tests pass successfully:

✔ 25 passing (11ms)

Total test suite remains healthy: 170 tests passing with no regressions.

Original prompt

write unit tests for this file- using the test instructions file

The user has attached the following files from their workspace:

  • src/features/execution/execUtils.ts
Created from VS Code via the [GitHub Pull Request](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extension.

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] write unit tests for... Add comprehensive unit tests for execUtils.ts Sep 30, 2025
@Copilot Copilot AI requested a review from eleanorjboyd September 30, 2025 21:57
Copilot finished work on behalf of eleanorjboyd September 30, 2025 21:57
@eleanorjboyd eleanorjboyd marked this pull request as ready for review October 1, 2025 17:15
@eleanorjboyd eleanorjboyd enabled auto-merge (squash) October 1, 2025 17:15
@vs-code-engineering vs-code-engineering bot added this to the September 2025 milestone Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants