Repository navigation
fix(testing): propagate PROJECT_ROOT_PATH and PYTHONPATH during test debugging - #26230
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 2 commits into
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 2 commits into
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 2 commits into
Conversation
…debugging Fixes microsoft#26155 When debugging tests (e.g. unittest with custom start directory `-s`), the debug configuration previously dropped `PROJECT_ROOT_PATH` and failed to assign the updated `PYTHONPATH` resulting from `addPathToPythonpath`. In addition, `execution.py` and `discovery.py` now consistently default `top_level_dir` to `PROJECT_ROOT_PATH` while preserving any explicitly specified `-t` option.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #26155
Description
When debugging unittest tests located in subdirectories (such as with
-s ./test), the debug execution previously failed to match test IDs, reporting tests as skipped with no output:debugLauncher.tspreviously omitted forwardingPROJECT_ROOT_PATHonto the debuggee's environment variables (launchArgs.env).addPathToPythonpathwas called without assigning the returned path back tolaunchArgs.env.PYTHONPATH.execution.pyanddiscovery.py,top_level_dirnow consistently defaults toPROJECT_ROOT_PATHwhen an explicit-ttop-level directory is not supplied.Changes
src/client/testing/common/debugLauncher.ts:launchArgs.env.PROJECT_ROOT_PATH = options.project.uri.fsPathwhenoptions.projectis provided.launchArgs.env.PYTHONPATH = addPathToPythonpath(additionalPythonPath, launchArgs.env.PYTHONPATH).python_files/unittestadapter/execution.py:top_level_dirtoproject_root_pathiftop_level_dirisNone.python_files/unittestadapter/discovery.py:top_level_dirtoproject_root_pathwhennot top_level_dir, preserving any explicit-targuments.src/test/testing/common/debugLauncher.unit.test.tsandpython_files/tests/unittestadapter/test_execution.py.