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

Support debugging individual Prism tests in VS Code #311

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"recommendations": [
// C++ intellisense with clangd.
"llvm-vs-code-extensions.vscode-clangd"
"llvm-vs-code-extensions.vscode-clangd",
// TODO: remove this before upstreaming
"vadimcn.vscode-lldb",
],
"unwantedRecommendations": [
// Microsoft C++ intellisense (doesn't work properly with Sorbet)
Expand Down
22 changes: 21 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
"ignoreFailures": false
}
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug Prism test in LLDB",
"program": "${workspaceFolder}/bazel-bin/test/test_PosTests/prism_regression/${input:test_name}.runfiles/com_stripe_ruby_typer/test/pipeline_test_runner",
"args": ["--single_test=${workspaceFolder}/test/prism_regression/${input:test_name}.rb", "--parser=prism"],
// See .vscode/tasks.json for the task that sets the `BAZEL_EXEC_ROOT` environment variable.
"preLaunchTask": "Prepare tests debugging",
"stopOnEntry": false,
"sourceMap": {
"${env:BAZEL_EXEC_ROOT}": "${workspaceFolder}",

Choose a reason for hiding this comment

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

Nice.

},
},
],
"inputs": [
{
"id": "test_name",
"type": "promptString",
"description": "Enter the test name, e.g. case for running test/prism_regression/case.rb",

Choose a reason for hiding this comment

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

Should we add a default, to give an example input?

Choose a reason for hiding this comment

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

Also, is there an equivalent to this:

// With this option, when running this task with the `Tasks: Rerun Last Test` command, it'll
// reuse the previous run's input, rather than prompting for it again
"runOptions": {
"reevaluateOnRerun": false
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally, I wouldn't use default for example. I think that's what description should do:

Screenshot 2024-10-29 at 14 57 42

Also, is there an equivalent to this:

No it's not available for launch entries. But the input should automatically be filled with the previous value by default. Does that not happen?

}
]
}
}
17 changes: 17 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@
"reveal": "always"
}
},
// This task:
// - Runs tests to generate the pipeline_test_runner files, which are needed by the LLDB
// debugger to execute the tests.
// - Sets the `BAZEL_EXEC_ROOT` environment variable, which is used by the LLDB
// debugger to find the source files.
{
"label": "Prepare tests debugging",
"type": "shell",
"command": "export BAZEL_EXEC_ROOT=$(./bazel info execution_root)",

Choose a reason for hiding this comment

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

IIRC it's beneficial to use the same configuration here, otherwise the Bazel server restarts

Suggested change
"command": "export BAZEL_EXEC_ROOT=$(./bazel info execution_root)",
"command": "export BAZEL_EXEC_ROOT=$(./bazel info execution_root --config=dbg)",

Copy link
Member Author

Choose a reason for hiding this comment

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

Does bazel info requires starting a server? I tried running it manually with/out the flag and I don't see any difference.

// We need to run tests first to get the pipeline_test_runner files generated
// Just building Sorbet with Prism doesn't generate them.
"dependsOn": ["Run all Prism tests"],
"hide": true,
"presentation": {
"reveal": "never",
}
}
],
"inputs": [
{
Expand Down
Loading