Skip to content
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

feat: better debug support #334

Merged
merged 23 commits into from Apr 13, 2024

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Apr 6, 2024

This PR improves the debugger support by utilizing the new inspector option. Also, a new option was added: vitest.debuggerAddress. With the vitest.debuggerPort, I think we can close #185 now.

Fixes #320
The debugger requires Vitest 1.5.0, but all other features work as they did with 1.4.0

@ffMathy
Copy link
Collaborator

ffMathy commented Apr 6, 2024

Would introducing some kind of state machine pattern help? I feel like it's one of those problems that could be solved by this.

@sheremet-va
Copy link
Member Author

Would introducing some kind of state machine pattern help?

Can you be more specific?

@ffMathy
Copy link
Collaborator

ffMathy commented Apr 6, 2024

Well, let's say that when pressing a particular button (like "start") has different effects in different states.

Maybe when we are in the ContinuousRun state, that button does something else than when we are in another state.

We can represent each state as a class implementing a particular interface with various inputs (onStartClicked) etc, and also allowing each state to control what other states are allowed to be switched to and from.

It's similar to the strategy pattern in a way. I don't know the specifics of the problem, but it sounds like you're describing complex flows that apply differently in particular states.

Can you describe the flows more detailed? Then I can come up with something probably.

Alternatively, for me, it helps drawing it as a state machine on a piece of paper.

@ffMathy
Copy link
Collaborator

ffMathy commented Apr 6, 2024

@ffMathy
Copy link
Collaborator

ffMathy commented Apr 6, 2024

And the pattern (you can create variants of it though): https://refactoring.guru/design-patterns/state

@sheremet-va
Copy link
Member Author

We can represent each state as a class implementing a particular interface with various inputs

I see what you mean now, but the problem here is not that we can't organize it, but that it's not possible to do several things at once - for example, you can't debug a test and collect other test files at the same time because Vitest only supports a single pool (it blocks other test runs until the current one is completed).

@ffMathy
Copy link
Collaborator

ffMathy commented Apr 6, 2024

Then each state class can have a property called "canDebug" etc, to represent that.

@sheremet-va
Copy link
Member Author

sheremet-va commented Apr 6, 2024

Then each state class can have a property called "canDebug" etc, to represent that.

Again, this has nothing to do with the code architecture. We need to be able to collect tests despite the debugging, single Vitest instance just doesn't allow that.

@ffMathy
Copy link
Collaborator

ffMathy commented Apr 8, 2024

Ah I see. My bad.

@sheremet-va sheremet-va marked this pull request as ready for review April 9, 2024 12:50
Copy link
Collaborator

@ffMathy ffMathy left a comment

Choose a reason for hiding this comment

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

Beautiful. Great work! Minor optional suggestions and preferences.

src/debug/debugManager.ts Show resolved Hide resolved
src/worker/actions.ts Outdated Show resolved Hide resolved
src/worker/actions.ts Outdated Show resolved Hide resolved
@sheremet-va sheremet-va merged commit e0a1f6b into vitest-dev:main Apr 13, 2024
1 check passed
@sheremet-va sheremet-va deleted the feat/debugger-support branch April 13, 2024 07:55
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.

Extension hangs if debugger is detached during a breakpoint pause Support Custom Launch Configurations
2 participants