You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- set FORCE_PYDEVD_VC_VARS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat
120
-
- set PYDEVD_FORCE_BUILD_ALL=True
121
120
- in the pydevd folder: python .\build_tools\build.py
122
121
122
+
## Pushing pydevd back to PyDev.Debugger
123
+
124
+
If you've made changes to pydevd (at src/debugpy/_vendored/pydevd), you'll want to push back changes to pydevd so as Fabio makes changes to pydevd we can continue to share updates.
125
+
126
+
### Setting up pydevd to be testable
127
+
128
+
Follow these steps to get pydevd testable:
129
+
130
+
- git clone https://github.com/fabioz/PyDev.Debugger (or using your own fork)
131
+
- copy all of your changes from src/debugpy/_vendored/pydevd to the root of your PyDev.Debugger clone
132
+
- remove the pdb files (pydevd doesn't ship those) if you rebuilt the attach dlls
133
+
- create an environment to test. The list of stuff in your environment is outlined [here](https://github.com/fabioz/PyDev.Debugger/blob/6cd4d431e6a794448f33a73857d479149041500a/.github/workflows/pydevd-tests-python.yml#L83).
134
+
135
+
### Testing pydevd and fixing test failures
136
+
137
+
Pydevd has a lot more tests on execution than debugpy. They reside in all of the `test` folders under the root. The majority of the execution tests are in the `tests_python` folder.
138
+
139
+
You run all of the tests with (from the root folder):
140
+
141
+
- python -m pytest -n auto -rfE
142
+
143
+
That will run all of the tests in parallel and output any failures.
144
+
145
+
If you want to just see failures you can do this:
146
+
147
+
- python -m pytest -n auto -q
148
+
149
+
That should generate output that just lists the tests which failed.
150
+
151
+
```
152
+
=============================================== short test summary info ===============================================
153
+
FAILED tests_python/test_debugger.py::test_path_translation[True] - AssertionError: TimeoutError (note: error trying to dump threads on timeout).
With that you can then run individual tests like so:
159
+
160
+
- python -m pytest -n auto tests_python/test_debugger.py::test_path_translation[False]
161
+
162
+
That will generate a log from the test run.
163
+
164
+
Logging the test output can be tricky so here's some information on how to debug the tests.
165
+
166
+
#### How to add more logging
167
+
168
+
The pydevd tests log everything to the console and to a text file during the test. If you scroll up in the console, it should show the log file it read the logs from:
If you want to add more logging in order to investigate something that isn't working, you simply add a line like so in the code:
176
+
177
+
```python
178
+
pydevd_log.debug("Some test logging", frame, etc)
179
+
```
180
+
181
+
Make sure if you add this in a module that gets `cythonized`, that you turn off `Cython` support as listed above. Otherwise you'll have to regen the C code or you won't actually see your new log output.
182
+
183
+
#### How to use logs to debug failures
184
+
185
+
Investigating log failures can be done in multiple ways.
186
+
187
+
If you have an existing test failing, you can investigate it by running the test with the main branch and comparing the results. To do so you would:
188
+
189
+
- Clone the repo a second time
190
+
- Change the code in `tests_python/debugger_unittest.py` so that the test prints out logs on success too (by default it only logs the output on a failure)
191
+
- Run the failing test in the second clone
192
+
- Run the failing test in your original clone
193
+
- Diff the results by finding the log file name in the output and diffing those two files
194
+
- Add more logging around where the differences first appear
195
+
- Repeat running and diffing
196
+
197
+
If you're adding a new test or just trying to figure out what the expected log output is, you would look at the failing test to see what steps are expected in the output. Here's an example:
In order to investigate a failure you'd look for the CMDs you expect and then see where the CMDs deviate. At that point you'd add logging around what might have happened next.
230
+
123
231
## Using modified debugpy in Visual Studio Code
124
232
To test integration between debugpy and Visual Studio Code, the latter can be directed to use a custom version of debugpy in lieu of the one bundled with the Python extension. This is done by specifying `"debugAdapterPath"` in `launch.json` - it must point at the root directory of the *package*, which is `src/debugpy` inside the repository:
0 commit comments