Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiroot workspace test discovery CWD differs between Refresh Tests and autoTestDiscoverOnSaveEnabled #22235

Closed
justinttl opened this issue Oct 16, 2023 · 4 comments
Assignees
Labels
area-testing triage-needed Needs assignment to the proper sub-team

Comments

@justinttl
Copy link

justinttl commented Oct 16, 2023

Type: Bug

Behaviour

Hi, I am seeing an issue in a multiroot workspace python monorepo, where Refresh Tests properly rescans all my python project tests but when test discovery on save runs, pytest collection is using an incorrect (often just the first) workspace's root as CWD.

Expected vs. Actual

Expected: Test discovery on save should use CWD based on root of workspace containing the opened/saved file. Or at least it should retrigger all workspace test disocovery using its respective CWD like with Refresh Test.

Actual: On save, pytest collects from the workspaceFolder of the first workspace I have, leading to errors that wipes any collected tests from "Refresh Tests". "Refresh Tests" is the only way I can get test explorer to repopulate.

Steps to reproduce:

  1. Create a multiroot workspace with >1 root (example, 2 workspaces A and B) with the follow config
    // Python Testing
    "python.testing.pytestEnabled": true,
    "python.testing.pytestArgs": ["--no-cov"],
    "python.testing.autoTestDiscoverOnSaveEnabled": true,

  1. Save a file on the second workspace
  2. See
2023-10-16 18:06:19.754 [info] Discover tests for workspace name: B - uri: /Users/justinlee/dev/project/b/file.py
2023-10-16 18:06:19.754 [info] Running discovery for pytest using the new test adapter.
2023-10-16 18:06:19.762 [info] > ~/Library/Caches/pypoetry/virtualenvs/a-py3.9/bin/python -m pytest -p vscode_pytest --collect-only --no-cov
2023-10-16 18:06:19.762 [info] cwd: ~/dev/project/a

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings

Multiroot scenario, following user settings may not apply:

envFile: "<placeholder>"

venvPath: "<placeholder>"

languageServer: "Pylance"

formatting
• provider: "black"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

terminal
• activateEnvironment: false

Extension version: 2023.18.0
VS Code version: Code 1.83.0 (Universal) (e7e037083ff4455cf320e344325dacb480062c3c, 2023-10-03T16:13:15.449Z)
OS version: Darwin arm64 21.6.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 10, 9, 9
Memory (System) 16.00GB (0.07GB free)
Process Argv merch.code-workspace --crash-reporter-id 104a0e4b-9af7-449a-96d1-a354071851b8
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30856252
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
3biah626:30602489
89544117:30613380
2i9eh265:30646982
showlangstatbar:30737416
962ge761:30841074
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
copilotsettingt:30859503
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30845448
pythonregdiag:30859691
pythonmypyd1cf:30859727

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 16, 2023
@eleanorjboyd eleanorjboyd self-assigned this Oct 17, 2023
@ezeholz
Copy link

ezeholz commented Oct 18, 2023

#22161 might be related. CWD not working as expected.

@justinttl
Copy link
Author

pythonTestAdapter seems to be the culprit as opting out of it seems to circumvent the issue.

@eleanorjboyd
Copy link
Member

Hello! This seems the same as #22218. I have just put in a fix on the pre-release version of the vscode-python extension and it is out today. Are you able to try it and see if that fixed it? Sorry for the delay in communicating that I was working on this issue!

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Oct 18, 2023
@justinttl
Copy link
Author

That did the trick! Thank you @eleanorjboyd

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Oct 18, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants