Add UI tests for attaching profilers to running processes#27
Add UI tests for attaching profilers to running processes#27
Conversation
- Introduce a new test file `attachProfiler.test.ts` to validate the functionality of attaching profilers (py-spy and memray) to running processes. - Implement tests to handle both valid and initially invalid PIDs, ensuring correct command generation and terminal output. - Utilize the VS Code Extension Tester framework for UI interactions and assertions, enhancing test coverage for profiling features.
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive UI test coverage for attaching profilers (py-spy and memray) to running processes. The tests validate the command prompt interaction flow and verify that the correct profiling commands are executed in the terminal.
- Adds end-to-end UI tests for py-spy and memray profiler attachment functionality
- Tests both valid PID scenarios and error recovery with invalid PIDs
- Validates command execution and terminal output verification
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import { BottomBarPanel, EditorView, TerminalView, Workbench } from 'vscode-extension-tester'; | ||
| import { retryOnError } from './helpers'; | ||
|
|
||
| const PID = '999999'; |
There was a problem hiding this comment.
The hardcoded PID '999999' is a magic number that may not represent a valid process ID in all test environments. Consider using a more descriptive constant name like MOCK_PID or TEST_PID to clarify this is a test fixture value.
| it(`Attach memray to running process`, async () => { | ||
| const prompt = await new Workbench().openCommandPrompt(); | ||
| await prompt.setText('>Flamegraph: Attach memray to running process'); | ||
| await prompt.selectQuickPick('Flamegraph: Attach memray to running process'); |
There was a problem hiding this comment.
This line appears redundant since line 48 already sets the command text. The selectQuickPick call with the same text may be unnecessary or could indicate a copy-paste error from another test pattern.
| await prompt.selectQuickPick('Flamegraph: Attach memray to running process'); |
attachProfiler.test.tsto validate the functionality of attaching profilers (py-spy and memray) to running processes.Note
Add UI tests that verify attaching py-spy and memray to a running PID (including invalid PID retry) via VS Code commands and terminal output.
src/ui-test/attachProfiler.test.ts):py-spyto a PID and expectingrecord --output profile.pyspy ... --pid 999999in terminal output.py-spy, asserting same command output.memrayto a PID, assertingattach --aggregate -f -o temp-memray-profile.bin 999999in terminal output.Written by Cursor Bugbot for commit 57b38fc. This will update automatically on new commits. Configure here.