Skip to content

Conversation

@rafaelha
Copy link
Owner

@rafaelha rafaelha commented Sep 27, 2025

  • Introduce a new test file attachProfiler.test.ts to 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.

  • UI tests (src/ui-test/attachProfiler.test.ts):
    • Validate attaching py-spy to a PID and expecting record --output profile.pyspy ... --pid 999999 in terminal output.
    • Validate retry flow: initial invalid PID, then valid PID for py-spy, asserting same command output.
    • Validate attaching memray to a PID, asserting attach --aggregate -f -o temp-memray-profile.bin 999999 in terminal output.
    • Use command palette interactions and terminal view setup/teardown for assertions.

Written by Cursor Bugbot for commit 57b38fc. This will update automatically on new commits. Configure here.

- 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.
@rafaelha rafaelha requested a review from Copilot September 27, 2025 20:35
Copy link
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 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';
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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');
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
await prompt.selectQuickPick('Flamegraph: Attach memray to running process');

Copilot uses AI. Check for mistakes.
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