Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Excluding files from being debugged #997

Closed
DonJayamanne opened this issue Nov 8, 2018 · 37 comments
Closed

Excluding files from being debugged #997

DonJayamanne opened this issue Nov 8, 2018 · 37 comments

Comments

@DonJayamanne
Copy link
Contributor

Environment data

  • PTVSD version: Master
  • OS and version: N/A
  • Python version (& distribution if applicable, e.g. Anaconda): N/A
  • Using VS Code or Visual Studio:VSC

Actual behavior

Unable to prevent files from being excluded from the debugger.

Expected behavior

Should be able to exclude files from being debugged.

Steps to reproduce:

Currently VSC is using the following API to exclude a file from being debugged:

import ptvsd
ptvsd.debugger.DONT_DEBUG.append(os.path.normcase(__file__))
@karthiknadig
Copy link
Member

Was this ever supported?

@DonJayamanne
Copy link
Contributor Author

Yes it was

@karthiknadig
Copy link
Member

@int19h I don't see DONT_DEBUG being used anywhere? was this supported in 3.* but never in 4.*?

@int19h
Copy link
Contributor

int19h commented Nov 8, 2018

Yes, that was a 3.x thing, and it was never intended to be a public API.

If we need this, we should do it right - i.e. expose some opaque functions to register such files.

@DonJayamanne
Copy link
Contributor Author

Can we increase the priority of this issue, thanks.
Or does the label feature-parity have an implicit priority attached to it.

@qubitron
Copy link

This is important for VS Code so adding back P1

@fabioz fabioz self-assigned this Jan 17, 2019
@fabioz
Copy link
Contributor

fabioz commented Jan 17, 2019

I'll take a look at this.

The suggestion is being able to configure through the launch config:

{
    "name": "Attach (Remote Debug)",
    "type": "python",
    "request": "attach",
    "port": 5678,
    "host": "localhost",
    "exclude": ["*bar.py", "*dir3*"].
    "includeDirs": ["/home/user/dir2"].
    "excludeDirs": ["/home/user/dir2/dir1"].
}

Some notes:
exclude can be any name (being directories or not) and has precedence over anything (so, if it matches it's always excluded).

includeDirs and excludeDirs need to map to directories and it's possible that one is inside the other (so, the one which matches the biggest path wins).

Does that sound reasonable? Is a Python API required too?

@karthiknadig
Copy link
Member

That sound good. We will need python API as well.

@qubitron
Copy link

My understanding at this time is that we only need the python API at this time.

We have another proposal for more specific include/exclude rules here:
https://github.com/Microsoft/vscode-python/issues/2087#issuecomment-425528613

Copying:

justMyCode.excludeModules: list of modules to exclude from my code
justMyCode.excludePaths: list of paths to exclude from my code (defaults to a $sitepackages variable, which would need to be added)
justMyCode.includeModules: list of modules to include as my code
justMyCode.includePaths: list of folders to include as my code

If you want to go ahead and implement the includePaths/excludePaths part of the proposal you are welcome to!

/cc @DonJayamanne

@DonJayamanne
Copy link
Contributor Author

My understanding at this time is that we only need the python API at this time.

@karthiknadig @qubitron The Python VSC Extension will not need the python api.
The extension can exclude the internal (extension specific) files from being debugged using the debug options.

Here's what I propose:

{
    "name": "AttachLaunch",
    "type": "python",
    "request": "attach|launch",
    "excludePaths": ["*bar.py", "*dir3*", "/project/tests/bar"]
    "includePaths": ["/home/user/dir2", "/home/user/dir4/*.py"]
}
  • Lets drop includeMoudles and excludeModules for now
  • Lets go with just the following:
justMyCode.excludePaths: list of paths to exclude from my code (defaults to a $sitepackages variable, which would need to be added)
justMyCode.includePaths: list of folders to include as my code

@karthiknadig
Copy link
Member

I believe python API is needed to provide exclusions. I understand this can be achieved via attach/launch settings, but being able to set this in python is needed.

If the python API work can be separated from the inclusion/exclusion support. Then python API is of lower priority.

@fabioz
Copy link
Contributor

fabioz commented Jan 18, 2019

The one downside I see with an includePaths/excludePaths with fnmatch-style matches is that in the case of nesting it's hard to reason which of the rules should have priority (i.e.: should it be the one which includes or the one which excludes it), whereas with an actual directory it's easy to reason about it (if there's one inside the other, the leaf one wins), which is why I had suggested includeDirs/excludeDirs with an additional exclude (which has priority over anything).

If only an includePaths/excludePaths is used, maybe I could check which ones map to real dirs and apply the same rule I had in mind for includeDirs/excludeDirs, but if a path matches both an exclude and an include fnmatch-style, which one should have preference?

Ideas?

@fabioz
Copy link
Contributor

fabioz commented Jan 18, 2019

I thought about it a bit more and I have a suggestion:

Let's go with the includePaths/excludePaths and let the include have priority (since everything is included by default, so, the rationale is that the user usually wants to exclude something and then include it back in nesting) and have additional settings so that the user could change what we see as project directories/library directories when he's using just my code (so, he could enable just my code and change the directories with proper nesting).

Also, the excludePaths/includePaths would always have priority over the just my code setting (so, it'd check that rule first and if there's no match it'd go on to the settings for just my code).

So, it'd be something as:

{
    "name": "AttachLaunch",
    "type": "python",
    "request": "attach|launch",
    "excludePaths": ["*bar.py", "*dir3*", "/project/tests/bar"],
    "includePaths": ["/home/user/dir2", "/home/user/dir4/*.py"],
    "libraryRoots": ["/path/to/lib"],
    "projectRoots": ["/path/to/lib/project"],
}

As a note, by default anything not considered to be a library is considered to be part of the project.

@DonJayamanne
Copy link
Contributor Author

Do we need "libraryRoots": ["/path/to/lib"], "projectRoots": ["/path/to/lib/project"],

Personally I find that confusing.
Id. Like to keep this as simple as possible, KISS.
The more settings we have, the more complicated it is to understand, configure and maintain..
Can we revisit it later.

As for the excludes, I would have expected that to take precedence. E.g. include everything in the current folder (default), but exclude a sub directory.
Isn't that the most likely use case?
I.e. wouldn't users generally be configuring just one setting such as excludes.

@fabioz
Copy link
Contributor

fabioz commented Jan 18, 2019

Ok, let's revisit later for the library/project roots if needed...

Regarding the include/exclude priority, let me give an example:

/dont_trace <- don't want to trace (add to exclude)
/dont_trace/my_code <- want to trace (add to include: only works if include has priority)
/my_code <- want to trace (great, nothing to do)
/my_code/dont_trace <- don't want to trace (add to exclude).

Does it seem ok or am I missing something?

Note that if there's an additional level on any case the rules wouldn't work because the rules aren't flexible enough (but that's probably a reasonable limitation).

@DonJayamanne
Copy link
Contributor Author

/dont_trace <- don't want to trace (add to exclude)
/dont_trace/my_code <- want to trace (add to include: only works if include has priority)

This doesn't feel intuitive to me, that's not how I would expect this setting to work.
It just add complications in explaining how this works to end users.

The way I'd solve your case is as follows:

/dont_trace/a <- don't want to trace (add to exclude)
/dont_trace/b <- don't want to trace (add to exclude)
/dont_trace/c <- don't want to trace (add to exclude)
/dont_trace/*.py <- don't want to trace (add to exclude)

/dont_trace/my_code <- want to trace (add to include)

Besides, I would have thought the primary use case of includePaths is to include files/folders that sit outside of the current project.

@fabioz
Copy link
Contributor

fabioz commented Jan 18, 2019 via email

@int19h
Copy link
Contributor

int19h commented Jan 18, 2019

Any case where you want to include a directory while excluding both its parent and some subdirectories in it.

It feels like the easiest way to do this is to just apply rules in order. This way, priority is explicit, and is controlled by the user. They would need to ensure that the more generic rules are at the beginning, ahead of more specific ones, but it is flexible enough to cover any scenario.

fabioz added a commit to fabioz/ptvsd that referenced this issue Jan 23, 2019
fabioz added a commit to fabioz/ptvsd that referenced this issue Jan 23, 2019
@fabioz
Copy link
Contributor

fabioz commented Jan 23, 2019

Ok, just provided a pull request based on that configuration.

Some notes on the implementation:

  • I haven't done an API on ptvsd (that configuration needs to be passed to the attach/launch request). If a Python API is needed, please let me know.

  • It's actually accepting glob patterns as I had already implemented it with that support -- when it doesn't have any special character it automatically does a path translation and if it maps to a dir it adds a /** to the end to be compatible with the spec (so, it's compatible with the spec but also accepts things as **/foo/*/bar).

  • Right now there are no default rules added with any path.

  • It'll first try to match based on one of the rules, if there are no matches to exclude nor include then the DebugStdLib setting is used to determine whether it should be traced or not.

@qubitron qubitron added this to the Jan 2019.2 milestone Jan 23, 2019
fabioz added a commit to fabioz/ptvsd that referenced this issue Jan 25, 2019
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Jan 28, 2019

FYI, please have a look at debugging nodejs in VSC, in particular the tooltips for files excluded in the stack Trace
https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_skipping-uninteresting-code-node-chrome

We might want to do the same

@DonJayamanne
Copy link
Contributor Author

@karthiknadig can we do the same for files excluded when using justmycode/debugStdLib?

@fabioz
Copy link
Contributor

fabioz commented Jan 28, 2019

@DonJayamanne it should be possible (ideally it should be done once pydevd itself provides the implementation of getting the stack using the debug adapter protocol).

I think this would be a separate issue thought.

@karthiknadig
Copy link
Member

@DonJayamanne Certainly that can be done for excluding files that way.

@fabio we have See https://github.com/Microsoft/ptvsd/issues/579 where we talk a bit more details about this.

@DonJayamanne
Copy link
Contributor Author

can we do the same for files excluded when using justmycode/debugStdLib?

Please note, by this i am referring to the tooltips.

@karthiknadig
Copy link
Member

I have not closed this item because we currently exclude files/dirs/modules only from stepping. The stack still shows frames from excluded files/dirs/modules.

@fabioz
Copy link
Contributor

fabioz commented Feb 8, 2019

@karthiknadig from what I understood that @DonJayamanne said, the idea was just graying them out and not really excluding (i.e.: add a presentationHint to make it subtle) right?

Note that I'm already on the process of porting the StackTraceRequest to pydevd, so, this should be straightforward to do as a second step (initially I don't want tests to change because of that while I'm doing the bigger change of porting that message to be handled by pydevd).

@karthiknadig
Copy link
Member

Yes, that is correct. Graying the frames from excluded files.

@karthiknadig karthiknadig modified the milestones: Feb 2019.1, Feb 2019.2 Feb 20, 2019
@karthiknadig karthiknadig modified the milestones: Feb 2019.2, Mar 2019.1 Mar 7, 2019
@karthiknadig karthiknadig removed this from the Mar 2019.1 milestone Mar 15, 2019
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Mar 20, 2019

Doesn't seem to work, I've tested this at my end, and here are the logs:
Instructions:

Note:

  • As you can see below I have excluded the extensions directory, the python file, the directory containing the pythno file.
  • However debugger still breaks in our python file.
11:53:43 AM, 3/20/2019
Started @ Wed Mar 20 2019 11:53:43 GMT-0700 (PDT)
From Client:
Content-Length: 324

{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code - Insiders","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
To Client:
Content-Length: 687

{"seq":1,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsExceptionInfoRequest":true,"supportsConfigurationDoneRequest":true,"supportsConditionalBreakpoints":true,"supportsSetVariable":true,"supportsExceptionOptions":true,"supportsEvaluateForHovers":true,"supportsModulesRequest":true,"supportsValueFormattingOptions":true,"supportsHitConditionalBreakpoints":true,"supportsSetExpression":true,"supportsLogPoints":true,"supportTerminateDebuggee":true,"supportsCompletionsRequest":true,"exceptionBreakpointFilters":[{"filter":"raised","label":"Raised Exceptions","default":false},{"filter":"uncaught","label":"Uncaught Exceptions","default":true}]}}
From Client:
Content-Length: 1238

{"command":"launch","arguments":{"name":"Unit Tests","type":"python","request":"launch","logToFile":true,"console":"none","cwd":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah","env":{},"envFile":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/.env","stopOnEntry":false,"showReturnValue":false,"redirectOutput":true,"debugStdLib":false,"rules":[{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode","include":false},{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py","include":false},{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/","include":false}],"program":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py","args":["--us=./tests","--up=*test*.py","--uvInt=2","--result-port=60480","-tunit_test.Test_CheckMyApp.test_complex_check","--testFile=/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/tests/unit_test.py"],"pythonPath":"/usr/bin/python","debugOptions":["RedirectOutput"],"workspaceFolder":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah","__sessionId":"0ec65d95-6ed8-43f8-ba5d-cddc83194c59"},"type":"request","seq":2}
To Client:
Content-Length: 1238


To Client:
{"command":"launch","arguments":{"name":"Unit Tests","type":"python","request":"launch","logToFile":true,"console":"none","cwd":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah","env":{},"envFile":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/.env","stopOnEntry":false,"showReturnValue":false,"redirectOutput":true,"debugStdLib":false,"rules":[{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode","include":false},{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py","include":false},{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/","include":false}],"program":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py","args":["--us=./tests","--up=*test*.py","--uvInt=2","--result-port=60480","-tunit_test.Test_CheckMyApp.test_complex_check","--testFile=/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/tests/unit_test.py"],"pythonPath":"/usr/bin/python","debugOptions":["RedirectOutput"],"workspaceFolder":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah","__sessionId":"0ec65d95-6ed8-43f8-ba5d-cddc83194c59"},"type":"request","seq":2}
To Client:
Content-Length: 324


To Client:
{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code - Insiders","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
To Client:
Content-Length: 132

{"body": {"category": "telemetry", "output": "ptvsd", "data": {"version": "4.2.5b2"}}, "type": "event", "event": "output", "seq": 0}
To Client:
Content-Length: 113

{"request_seq": 2, "body": {}, "seq": 1, "success": true, "command": "launch", "message": "", "type": "response"}
To Client:
Content-Length: 866

{"request_seq": 1, "body": {"supportsModulesRequest": true, "supportsConfigurationDoneRequest": true, "supportsDelayedStackTraceLoading": true, "supportsDebuggerProperties": true, "supportsEvaluateForHovers": true, "supportsSetExpression": true, "supportsExceptionOptions": true, "exceptionBreakpointFilters": [{"filter": "raised", "default": false, "label": "Raised Exceptions"}, {"filter": "uncaught", "default": true, "label": "Uncaught Exceptions"}], "supportsCompletionsRequest": true, "supportsExceptionInfoRequest": true, "supportsLogPoints": true, "supportsValueFormattingOptions": true, "supportsHitConditionalBreakpoints": true, "supportsSetVariable": true, "supportTerminateDebuggee": true, "supportsGotoTargetsRequest": false, "supportsConditionalBreakpoints": true}, "seq": 2, "success": true, "command": "initialize", "message": "", "type": "response"}
To Client:
Content-Length: 63

{"body": {}, "type": "event", "event": "initialized", "seq": 3}
From Client:
Content-Length: 247

{"command":"setBreakpoints","arguments":{"source":{"name":"unit_test.py","path":"/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/tests/unit_test.py"},"lines":[6],"breakpoints":[{"line":6}],"sourceModified":false},"type":"request","seq":3}
To Client:
Content-Length: 176

{"request_seq": 3, "body": {"breakpoints": [{"line": 6, "verified": true, "id": 0}]}, "seq": 4, "success": true, "command": "setBreakpoints", "message": "", "type": "response"}
From Client:
Content-Length: 99

{"command":"setExceptionBreakpoints","arguments":{"filters":["uncaught"]},"type":"request","seq":4}
To Client:
Content-Length: 130

{"request_seq": 4, "body": {}, "seq": 5, "success": true, "command": "setExceptionBreakpoints", "message": "", "type": "response"}
From Client:
Content-Length: 56

{"command":"configurationDone","type":"request","seq":5}
To Client:
Content-Length: 248

{"body": {"systemProcessId": 63863, "startMethod": "launch", "name": "/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py", "isLocalProcess": true}, "type": "event", "event": "process", "seq": 6}Content-Length: 124


To Client:
{"request_seq": 5, "body": {}, "seq": 7, "success": true, "command": "configurationDone", "message": "", "type": "response"}
From Client:
Content-Length: 46

{"command":"threads","type":"request","seq":6}
To Client:
Content-Length: 92

{"body": {"reason": "started", "threadId": 1}, "type": "event", "event": "thread", "seq": 8}
To Client:
Content-Length: 158

{"request_seq": 6, "body": {"threads": [{"id": 1, "name": "MainThread"}]}, "seq": 9, "success": true, "command": "threads", "message": "", "type": "response"}
From Client:
Content-Length: 46

{"command":"threads","type":"request","seq":7}
To Client:
Content-Length: 93

{"body": {"reason": "started", "threadId": 2}, "type": "event", "event": "thread", "seq": 10}
To Client:
Content-Length: 153

{"body": {"category": "stderr", "output": "test_complex_check (unit_test.Test_CheckMyApp)", "source": {}}, "type": "event", "event": "output", "seq": 11}
To Client:
Content-Length: 112


To Client:
{"body": {"category": "stderr", "output": " ... ", "source": {}}, "type": "event", "event": "output", "seq": 12}Content-Length: 109

{"body": {"category": "stderr", "output": "ok", "source": {}}, "type": "event", "event": "output", "seq": 13}Content-Length: 109

{"body": {"category": "stderr", "output": "\n", "source": {}}, "type": "event", "event": "output", "seq": 14}
To Client:
Content-Length: 109

{"body": {"category": "stderr", "output": "\n", "source": {}}, "type": "event", "event": "output", "seq": 15}Content-Length: 177

{"body": {"category": "stderr", "output": "----------------------------------------------------------------------", "source": {}}, "type": "event", "event": "output", "seq": 16}
To Client:
Content-Length: 109

{"body": {"category": "stderr", "output": "\n", "source": {}}, "type": "event", "event": "output", "seq": 17}Content-Length: 127

{"body": {"category": "stderr", "output": "Ran 1 test in 0.002s", "source": {}}, "type": "event", "event": "output", "seq": 18}
To Client:
Content-Length: 109

{"body": {"category": "stderr", "output": "\n", "source": {}}, "type": "event", "event": "output", "seq": 19}Content-Length: 109

{"body": {"category": "stderr", "output": "\n", "source": {}}, "type": "event", "event": "output", "seq": 20}
To Client:
Content-Length: 109

{"body": {"category": "stderr", "output": "OK", "source": {}}, "type": "event", "event": "output", "seq": 21}Content-Length: 109

{"body": {"category": "stderr", "output": "\n", "source": {}}, "type": "event", "event": "output", "seq": 22}
To Client:
Content-Length: 189

{"request_seq": 7, "body": {"threads": [{"id": 1, "name": "MainThread"}, {"id": 2, "name": "Dummy-6"}]}, "seq": 23, "success": true, "command": "threads", "message": "", "type": "response"}
To Client:
Content-Length: 208


To Client:
{"body": {"preserveFocusHint": false, "description": "False", "text": "exceptions.SystemExit", "allThreadsStopped": true, "reason": "exception", "threadId": 1}, "type": "event", "event": "stopped", "seq": 24}
From Client:
Content-Length: 46

{"command":"threads","type":"request","seq":8}
To Client:
Content-Length: 189

{"request_seq": 8, "body": {"threads": [{"id": 1, "name": "MainThread"}, {"id": 2, "name": "Dummy-6"}]}, "seq": 25, "success": true, "command": "threads", "message": "", "type": "response"}
From Client:
Content-Length: 103

{"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":20},"type":"request","seq":9}
To Client:
Content-Length: 253

{"body": {"reason": "new", "module": {"path": "/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py", "version": "3.0.0.0", "id": 0, "name": "__main__"}}, "type": "event", "event": "module", "seq": 26}
To Client:
Content-Length: 203


To Client:
{"body": {"reason": "new", "module": {"path": "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", "id": 1, "name": "runpy"}}, "type": "event", "event": "module", "seq": 27}
To Client:
Content-Length: 584

{"request_seq": 9, "body": {"totalFrames": 2, "stackFrames": [{"column": 1, "source": {"path": "/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py", "sourceReference": 0}, "line": 325, "id": 140202392123296, "name": "main"}, {"column": 1, "source": {"path": "/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py", "sourceReference": 0}, "line": 347, "id": 4346804896, "name": "<module>"}]}, "seq": 28, "success": true, "command": "stackTrace", "message": "", "type": "response"}
From Client:
Content-Length: 80

{"command":"exceptionInfo","arguments":{"threadId":1},"type":"request","seq":10}
To Client:
Content-Length: 1044

{"request_seq": 10, "body": {"breakMode": "unhandled", "details": {"typeName": "exceptions.SystemExit", "message": "False", "source": "/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py", "stackTrace": "  File \"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py\", line 344, in main\n  File \"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py\", line 347, in <module>\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py\", line 72, in _run_code\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py\", line 82, in _run_module_code\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py\", line 240, in run_path\n"}, "description": "False", "exceptionId": "exceptions.SystemExit"}, "seq": 29, "success": true, "command": "exceptionInfo", "message": "", "type": "response"}
From Client:
Content-Length: 47

{"command":"threads","type":"request","seq":11}
To Client:
Content-Length: 190

{"request_seq": 11, "body": {"threads": [{"id": 1, "name": "MainThread"}, {"id": 2, "name": "Dummy-6"}]}, "seq": 30, "success": true, "command": "threads", "message": "", "type": "response"}
From Client:
Content-Length: 86

{"command":"scopes","arguments":{"frameId":140202392123296},"type":"request","seq":12}
To Client:
Content-Length: 218

{"request_seq": 12, "body": {"scopes": [{"variablesReference": 140202392123296, "source": {}, "name": "Locals", "expensive": false}]}, "seq": 31, "success": true, "command": "scopes", "message": "", "type": "response"}
From Client:
Content-Length: 100

{"command":"variables","arguments":{"variablesReference":140202392123296},"type":"request","seq":13}
To Client:
Content-Length: 4066

{"request_seq": 13, "body": {"variables": [{"variablesReference": 4347159440, "type": "classobj", "evaluateName": "OptionParser", "name": "OptionParser", "value": "<class optparse.OptionParser at 0x1031c6390>"}, {"variablesReference": 4347150032, "type": "TestSuite", "evaluateName": "cls", "name": "cls", "value": "<unittest.suite.TestSuite tests=[<unit_test.Test_CheckMyApp testMethod=test_complex_check>, <unit_test.Test_CheckMyApp testMethod=test_simple_check>]>"}, {"type": "NoneType", "evaluateName": "cov", "name": "cov", "value": "None"}, {"variablesReference": 4347148432, "type": "TestLoader", "evaluateName": "loader", "name": "loader", "value": "<unittest.loader.TestLoader object at 0x1031c3890>"}, {"variablesReference": 4347150096, "type": "Test_CheckMyApp", "evaluateName": "m", "name": "m", "value": "<unit_test.Test_CheckMyApp testMethod=test_complex_check>"}, {"variablesReference": 4347180168, "type": "Values", "evaluateName": "opts", "name": "opts", "value": "<Values at 0x1031cb488: {'tests': ['unit_test.Test_CheckMyApp.test_complex_check'], 'result_port': 60480, 'ut': None, 'up': '*test*.py', 'us': './tests', 'mixed_mode': None, 'uc': None, 'coverage': None, 'debug': None, 'uvInt': 2, 'uf': None, 'testFile': '/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/tests/unit_test.py'}>"}, {"variablesReference": 4334767080, "type": "module", "evaluateName": "os", "name": "os", "value": "<module 'os' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc'>"}, {"variablesReference": 4347504328, "type": "OptionParser", "evaluateName": "parser", "name": "parser", "value": "<optparse.OptionParser instance at 0x10321a6c8>"}, {"variablesReference": 4347240528, "type": "VsTestResult", "evaluateName": "result", "name": "result", "value": "<__main__.VsTestResult run=1 errors=0 failures=0>"}, {"variablesReference": 4347150224, "type": "TextTestRunner", "evaluateName": "runner", "name": "runner", "value": "<unittest.runner.TextTestRunner object at 0x1031c3f90>"}, {"variablesReference": 4347150032, "type": "TestSuite", "evaluateName": "suite", "name": "suite", "value": "<unittest.suite.TestSuite tests=[<unit_test.Test_CheckMyApp testMethod=test_complex_check>, <unit_test.Test_CheckMyApp testMethod=test_simple_check>]>"}, {"variablesReference": 4347149008, "type": "TestSuite", "evaluateName": "suites", "name": "suites", "value": "<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<unit_test.Test_CheckMyApp testMethod=test_complex_check>, <unit_test.Test_CheckMyApp testMethod=test_simple_check>]>]>]>"}, {"variablesReference": 4334386096, "type": "module", "evaluateName": "sys", "name": "sys", "value": "<module 'sys' (built-in)>"}, {"type": "str", "presentationHint": {"attributes": ["rawString"]}, "evaluateName": "testId", "name": "testId", "value": "'unit_test.Test_CheckMyApp.test_complex_check'"}, {"variablesReference": 4347149200, "type": "TestSuite", "evaluateName": "test_suite", "name": "test_suite", "value": "<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<unit_test.Test_CheckMyApp testMethod=test_complex_check>, <unit_test.Test_CheckMyApp testMethod=test_simple_check>]>]>"}, {"variablesReference": 4347240592, "type": "TestSuite", "evaluateName": "tests", "name": "tests", "value": "<unittest.suite.TestSuite tests=[<unit_test.Test_CheckMyApp testMethod=test_complex_check>]>"}, {"variablesReference": 4346578432, "type": "module", "evaluateName": "unittest", "name": "unittest", "value": "<module 'unittest' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/__init__.pyc'>"}, {"variablesReference": 4346780416, "type": "list", "evaluateName": "_", "name": "_", "value": "[]"}, {"variablesReference": 4347218832, "type": "tuple", "evaluateName": "__exception__", "name": "__exception__", "value": "(<type 'exceptions.SystemExit'>, SystemExit(False,), <traceback object at...10323e5a8>)"}]}, "seq": 32, "success": true, "command": "variables", "message": "", "type": "response"}
From Client:
Content-Length: 75

{"command":"continue","arguments":{"threadId":1},"type":"request","seq":14}
To Client:
Content-Length: 75

{"body": {"threadId": 1}, "type": "event", "event": "continued", "seq": 33}
To Client:
Content-Length: 92

{"body": {"reason": "exited", "threadId": 1}, "type": "event", "event": "thread", "seq": 34}
To Client:
Content-Length: 144

{"request_seq": 14, "body": {"allThreadsContinued": true}, "seq": 35, "success": true, "command": "continue", "message": "", "type": "response"}
To Client:
Content-Length: 72

{"body": {"exitCode": 0}, "type": "event", "event": "exited", "seq": 36}
onEventTerminated
To Client:
Content-Length: 63

{"body": {}, "type": "event", "event": "terminated", "seq": 37}
From Client:
Content-Length: 80

{"command":"disconnect","arguments":{"restart":false},"type":"request","seq":15}
To Client:
Content-Length: 119


onResponseDisconnect
To Client:
{"request_seq": 15, "body": {}, "seq": 38, "success": true, "command": "disconnect", "message": "", "type": "response"}
check and shutdown
shutdown
killing process
Socket End
check and shutdown
check and shutdown
Kill process now
Shutting down debug session
disposing

@fabioz
Copy link
Contributor

fabioz commented Mar 21, 2019

@DonJayamanne I've been able to reproduce the issue related to the SystemExit (it seems that the visualstudio_py_testlauncher.py is not being considered as an internal file, so, I'll fix that).

Now, related to the issue on rules, on a simple case it worked for me (when running a regular file on Python 3.6/Linux).

Now, the case I tested wasn't a unit-test... I couldn't discover where to specify the rules for the debug launch (didn't find anything at https://code.visualstudio.com/docs/python/unit-testing) -- clicking on the Debug Test doesn't seem to create a related launch config to edit... can you give me some instructions how to run a test customizing the launch on VSCode?

Also, is it working for you on a regular launch? Which Python version/OS are you testing?

@DonJayamanne
Copy link
Contributor Author

(it seems that the visualstudio_py_testlauncher.py is not being considered as an internal file, so, I'll fix that).

Please do not hard code this, I'm currently using the API to pass in the rules and it is not being excluded.
As you can see here, I'm passing the folder, file to exclude, but nothing seems to work.

"rules":[
	{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode","include":false}, 
	{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/visualstudio_py_testlauncher.py","include":false},
	{"path":"/Users/donjayamanne/.vscode-insiders/extensions/pythonVSCode/pythonFiles/","include":false}]
}

Now, the case I tested wasn't a unit-test... I couldn't discover where to specify the rules for the debug launch

There's no way to do this, that's why I've uploaded the vsix above.

Also, is it working for you on a regular launch?

Have not tested.

Which Python version/OS are you testing?

OSX, Python 3.7

@fabioz
Copy link
Contributor

fabioz commented Mar 27, 2019

I've created a different issue to address this: #1268 (so, closing this one).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants