-
Notifications
You must be signed in to change notification settings - Fork 36
Add comprehensive unit tests for execUtils.ts #873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eleanorjboyd
merged 8 commits into
main
from
copilot/fix-3b6de93e-8dce-49f5-8cd1-5f79d0da7ad8
Oct 14, 2025
Merged
Add comprehensive unit tests for execUtils.ts #873
eleanorjboyd
merged 8 commits into
main
from
copilot/fix-3b6de93e-8dce-49f5-8cd1-5f79d0da7ad8
Oct 14, 2025
Conversation
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
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
TylerLeonhardt
approved these changes
Oct 14, 2025
NguyenCuong1989
referenced
this pull request
in NguyenCuong1989/vscode-python-environments
Oct 23, 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. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > 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 > > </details> Created from VS Code via the [GitHub Pull Request](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extension. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start the survey. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
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.
This PR adds comprehensive unit test coverage for the
execUtils.tsutility functions that handle argument quoting for command execution.Overview
The
execUtils.tsmodule 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 argumentsThese 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.tswith 25 comprehensive tests:quoteStringIfNecessarytests (15 tests):quoteArgstests (10 tests):--flag "value with spaces")Testing Approach
Following the repository's testing workflow instructions:
*.unit.test.tsnaming convention for fast, isolated testingVerification
All tests pass successfully:
Total test suite remains healthy: 170 tests passing with no regressions.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.