microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.33k stars 1.19k forks source link

Custom config for testing and debug v2 design #23907

Open cwebster-99 opened 3 months ago

cwebster-99 commented 3 months ago

In previous iterations we created a V1/MVP for a custom config design for testing and debugging. In this upcoming iteration we will work on iterating for a V2

eleanorjboyd commented 2 months ago

The following is the new V2 design as formulated by @cwebster-99 and I. These would be found / placed in the launch.json

design for testing

{
      "name": "default test config on UI creation",
      "type": "debugpy", ?
      "request": "launch",
      "purpose": ["discover-test", "run-test", "debug-test"],
      "presentation": "hidden",
} // This is what would happen if a user went through the basic setup flow
{
      "name": "discovery or execution, all possible attributes",
      "type": "python", ?
      "request": "launch",
      "purpose": ["discover-test"],
      "presentation": "hidden",
      "args": []
      "env" : {},
            "cwd" : '',
            "envFile" : '',
} // These are all possible attributes allowed if the type is "discover-test" or "run-test"
// if user also has debug-test the others will be possible but will not impact discovery or run 
// unless these attributes are explicitly listed as test supported

debug test

For "debug-test" allow all attributes currently supported by the python debugger

justMyCode
console
autoReload
consoleTitle // core
debugAdapterPath
debugServer //core
gevent
internalConsoleOptions // core
linux // check
logToFile
osx // check
pathMappings
postDebugTask // core
preLaunchTask // core
presentation
redirectOutput
serverReadyAction
showReturnValue
stopOnEntry
subProcess
suppressMultipleSessionWarning //core
windows // check
pythonArgs // check with Karthik ( pass to the interpreter itself)
args
pyramid
module ?
env 
cwd
envFile
program 
framework: [jinja, django] //debugpy, I can decide settings.json vs debugpy
host
port
sudo
listen
connect

Run button / non-test scenarios

{
      "name": "run config for file run button",
      "type": "python", ?
      "request": "launch",
      "presentation": "hidden",
     "noDebug": "true"
} 

Here a user could specify they do not want a launch.json config to be used for debugging but again an opt out instead of an opt in scenario.

Questions:

  1. What should the type be for the multiple different configs? Having something of type "debugpy" doesn't really make sense when the purpose is just "test-discovery" or "test-run"
  2. What do people think of "noDebug" as a specification? Do we think this is another opt out parameter that is non-default? Is that the right name for it?
  3. Is hidden our desired default for all config types?
  4. What happens if someone includes a param like "justMyCode" but do not debug? How do we signal that will not be used?
cwebster-99 commented 2 months ago

What do people think of "noDebug" as a specification? Do we think this is another opt out parameter that is non-default? Is that the right name for it?

Along these lines, one more consideration is on the Run button / non-test scenarios should we be including purpose: "run", "debug" by default or just use nodebug attribute to control when something is run and debug vs not. I am not sure how discoverable this maybe or if we should standardize with the test configs. It might be a bit redundant to have purpose and nodebug...Looking for thoughts :)

cwebster-99 commented 2 months ago

Notes/Edits after discussion:

cwebster-99 commented 2 months ago

These would be found / placed in the launch.json

design for testing

{
      "name": "default test config on UI creation",
      "type": "pythonTest", 
      "request": "launch",
      "presentation": "hidden",
} // This is what would happen if a user went through the basic setup flow
{
      "name": "discovery or execution, all possible attributes",
      "type": "pythonTest", ?
      "request": "launch",
      "purpose": ["discover-test"],
      "presentation": "hidden",
      "args": []
      "env" : {},
            "cwd" : '',
            "envFile" : '',
} // These are all possible attributes allowed if the type is "discover-test" or "run-test"
// if user also has debug-test the others will be possible but will not impact discovery or run 
// unless these attributes are explicitly listed as test supported

debug test

For "debug-test" allow all attributes currently supported by the python debugger

justMyCode
console
autoReload
consoleTitle // core
debugAdapterPath
debugServer //core
gevent
internalConsoleOptions // core
linux // check
logToFile
osx // check
pathMappings
postDebugTask // core
preLaunchTask // core
presentation
redirectOutput
serverReadyAction
showReturnValue
stopOnEntry
subProcess
suppressMultipleSessionWarning //core
windows // check
pythonArgs // check with Karthik ( pass to the interpreter itself)
args
pyramid
module ?
env 
cwd
envFile
program 
framework: [jinja, django] //debugpy, I can decide settings.json vs debugpy
host
port
sudo
listen
connect

Run button / non-test scenarios

{
      "name": "run config for file run button",
      "type": "debugpy", 
      "request": "launch",
     "noDebug": "true"
} 

Debug configs remain unchanged :)