Skip to content

Commit

Permalink
Merge pull request #311 from Shopify/improve-debugger-integration
Browse files Browse the repository at this point in the history
Support debugging individual Prism tests in VS Code
  • Loading branch information
st0012 authored Oct 29, 2024
2 parents f1e5aea + bab4eb4 commit 6ff11c3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
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}",
},
},
],
"inputs": [
{
"id": "test_name",
"type": "promptString",
"description": "Enter the test name, e.g. case for running test/prism_regression/case.rb",
}
]
}
}
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)",
// 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

0 comments on commit 6ff11c3

Please sign in to comment.