microsoft / vscode-python

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

Tests in in Test Explorer are seen but do nothing with a symlinked folder #23223

Closed alanwilter closed 6 months ago

alanwilter commented 7 months ago

Type: Bug

It's still about https://github.com/microsoft/vscode-python/issues/22658#issuecomment-1938747836

I have this symlink: /Users/alan/Projects -> '/Users/alan/Library/Mobile Documents/com~apple~CloudDocs/Projects' And my project ~/Projects/face-ai when opened with VScode:

code ~/Projects/face-ai

seems all fine except that running the Tests does not do anything!

Screenshot 2024-04-11 at 10 58 43

If I open with original path:

code "/Users/alan/Library/Mobile Documents/com~apple~CloudDocs/Projects/face-ai"

Everything works fine.

Screenshot 2024-04-11 at 11 01 19

I suspect that the whitespace in the symlink can be the cause.

I cannot change /Users/alan/Library/Mobile Documents/com~apple~CloudDocs beacuse this is from macOS and it's the place for iClouds, where I keep my projects backed up in the cloud.

Extension version: 2024.4.1 VS Code version: Code 1.88.0 (5c3e652f63e798a5ac2f31ffd0d863669328dc4c, 2024-04-03T13:28:09.495Z) OS version: Darwin arm64 23.4.0 Modes: Remote OS version: Linux x64 5.4.0-91-generic Connection to 'SSH: toverdrive' could not be established Canceled Connection to 'SSH: toverdrive' could not be established Canceled Connection to 'SSH: toverdrive' could not be established Canceled

User Settings

``` languageServer: "Pylance" testing • pytestArgs: "" • pytestEnabled: true terminal • launchArgs: "" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |Auto Time Stamp|lpubsppop01.vscode-auto-timestamp|0.0.8| |autoDocstring - Python Docstring Generator|njpwerner.autodocstring|0.6.1| |AWS boto3|Boto3typed.boto3-ide|0.5.4| |AWS Toolkit - Amazon Q, CodeWhisperer, and more|amazonwebservices.aws-toolkit-vscode|2.18.0| |Base64Viewer|JasonMejane.base64viewer|1.5.2| |Bash Debug|rogalmic.bash-debug|0.3.9| |Bash IDE|mads-hartmann.bash-ide-vscode|1.39.0| |C/C++|ms-vscode.cpptools|1.19.9| |ChatGPT - Genie AI|genieai.chatgpt-vscode|0.0.10| |Code Runner|formulahendry.code-runner|0.12.2| |Code Spell Checker|streetsidesoftware.code-spell-checker|3.0.1| |CodeLLDB|vadimcn.vscode-lldb|1.10.0| |Continue - Claude, CodeLlama, GPT-4, and more|Continue.continue|0.9.108| |Conventional Commits|vivaxy.vscode-conventional-commits|1.25.0| |Coverage Gutters|ryanluker.vscode-coverage-gutters|2.11.1| |crates|serayuzgur.crates|0.6.6| |Crystal Language|crystal-lang-tools.crystal-lang|0.9.3| |Debugger for Firefox|firefox-devtools.vscode-firefox-debug|2.9.10| |Dev Containers|ms-vscode-remote.remote-containers|0.354.0| |DICOM Tag Dump|smikitky.vscode-dicom|1.4.0| |Docker|ms-azuretools.vscode-docker|1.29.0| |Duplicate action|mrmlnc.vscode-duplicate|1.2.1| |Edit csv|janisdd.vscode-edit-csv|0.9.1| |Edit with Shell Command|ryu1kn.edit-with-shell|1.3.0| |EditorConfig for VS Code|EditorConfig.EditorConfig|0.16.4| |endwise|kaiwood.endwise|1.5.1| |ESLint|dbaeumer.vscode-eslint|2.4.4| |ev3dev-browser|ev3dev.ev3dev-browser|1.2.1| |Even Better TOML|tamasfe.even-better-toml|0.19.2| |filesize|mkxml.vscode-filesize|3.1.0| |Git Graph|mhutchie.git-graph|1.30.0| |Git History|donjayamanne.githistory|0.6.20| |GitHub Actions|github.vscode-github-actions|0.26.2| |GitHub Codespaces|GitHub.codespaces|1.16.19| |GitHub Pull Requests|GitHub.vscode-pull-request-github|0.86.1| |GitLens — Git supercharged|eamodio.gitlens|14.9.0| |Gitpod|gitpod.gitpod-desktop|0.0.164| |H5Web|h5web.vscode-h5web|0.1.3| |iconfont-preview|stxr.iconfont-preview|0.0.5| |Insert Date String|jsynowiec.vscode-insertdatestring|2.3.1| |JavaScript Debugger|ms-vscode.js-debug|1.88.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |JPEG-2000 Preview|analytic-signal.preview-jp2|0.0.4| |Jupyter|ms-toolsai.jupyter|2024.3.1| |Jupyter Cell Tags|ms-toolsai.vscode-jupyter-cell-tags|0.1.9| |Jupyter Keymap|ms-toolsai.jupyter-keymap|1.1.2| |Jupyter Notebook Renderers|ms-toolsai.jupyter-renderers|1.0.17| |Jupyter Slide Show|ms-toolsai.vscode-jupyter-slideshow|0.1.6| |LEGO® MINDSTORMS® EV3 MicroPython|lego-education.ev3-micropython|2.0.0| |Live Preview|ms-vscode.live-server|0.4.13| |Live Share|ms-vsliveshare.vsliveshare|1.0.5918| |Makefile Tools|ms-vscode.makefile-tools|0.9.10| |Markdown All in One|yzhang.markdown-all-in-one|3.6.2| |markdownlint|DavidAnson.vscode-markdownlint|0.54.0| |Material Icon Theme|PKief.material-icon-theme|4.34.0| |Meld Diff|danielroedl.meld-diff|1.4.1| |Mypy Type Checker|ms-python.mypy-type-checker|2023.6.0| |MySQL|formulahendry.vscode-mysql|0.5.0| |npm Intellisense|christian-kohler.npm-intellisense|1.4.5| |Playwright Test for VSCode|ms-playwright.playwright|1.0.22| |Prettier - Code formatter|esbenp.prettier-vscode|10.4.0| |Pylance|ms-python.vscode-pylance|2024.4.1| |Python|ms-python.python|2024.4.1| |Python Debugger|ms-python.debugpy|2024.4.0| |python-snippets|cstrap.python-snippets|0.1.2| |python-string-sql|ptweir.python-string-sql|1.2.0| |R|REditorSupport.r|2.8.2| |R Debugger|RDebugger.r-debugger|0.5.4| |Rainbow CSV|mechatroner.rainbow-csv|3.11.0| |RBS Syntax Highlighting|GracefulPotato.rbs-syntax|0.3.0| |Remote - SSH|ms-vscode-remote.remote-ssh|0.110.1| |Remote - SSH: Editing Configuration Files|ms-vscode-remote.remote-ssh-edit|0.86.0| |Remote - Tunnels|ms-vscode.remote-server|1.5.1| |Remote Explorer|ms-vscode.remote-explorer|0.4.3| |reStructuredText|lextudio.restructuredtext|189.3.0| |reStructuredText Syntax highlighting|trond-snekvik.simple-rst|1.5.4| |Ruby LSP|Shopify.ruby-lsp|0.5.17| |Ruby Solargraph|castwide.solargraph|0.24.1| |ruby-rubocop|misogi.ruby-rubocop|0.8.6| |Ruff|charliermarsh.ruff|2024.16.0| |rust-analyzer|rust-lang.rust-analyzer|0.4.1919| |Shebang Snippets|rpinski.shebang-snippets|0.1.4| |shell-format|foxundermoon.shell-format|7.2.5| |ShellCheck|timonwong.shellcheck|0.37.0| |shellman|Remisa.shellman|5.7.0| |sidebar-markdown-notes|assisrMatheus.sidebar-markdown-notes|1.2.0| |SQLite|alexcvzz.vscode-sqlite|0.14.1| |SVG|jock.svg|1.5.3| |Swift|sswg.swift-lang|1.8.1| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.8| |TIFF Preview|analytic-signal.preview-tiff|1.0.1| |Todo Tree|Gruntfuggly.todo-tree|0.0.226| |Turbo Console Log|ChakrounAnas.turbo-console-log|2.10.4| |vscode-icons|vscode-icons-team.vscode-icons|12.7.0| |vscode-pdf|tomoki1207.pdf|1.2.2| |WSL|ms-vscode-remote.remote-wsl|0.88.0| |YAML|redhat.vscode-yaml|1.14.0| |Zip File Explorer|slevesque.vscode-zipexplorer|0.3.1| |ZipFS - a zip file system|arcanis.vscode-zipfs|3.0.0|
System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 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
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|40, 56, 48| |Memory (System)|64.00GB (3.74GB free)| |Process Argv|--remote ssh-remote+toverdrive /home/awilter/AWS_DEMO_LOCALHOST_2_CLOUD --crash-reporter-id d42c285a-75a9-4203-a778-028b68b74075| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: toverdrive| |OS|Linux x64 5.4.0-91-generic| |CPUs|AMD Ryzen Threadripper PRO 5975WX 32-Cores (64 x 3432)| |Memory (System)|251.60GB (192.54GB free)| |VM|0%| Connection to 'SSH: toverdrive' could not be established Canceled Connection to 'SSH: toverdrive' could not be established Canceled Connection to 'SSH: toverdrive' could not be established Canceled
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp2r6:30993542 dsvsc020:30976470 pythonait:31006305 jchc7451:30973076 gee8j676:31009558 dsvsc021:30996838 gd77d436:30999572 bdiig495:31013172 ```
eleanorjboyd commented 6 months ago

Hi! Sorry for the delay, I was on vacation, will take a look at this shortly

eleanorjboyd commented 6 months ago

Hi! Was looking through this and tried both with: ln -s "/Users/eleanorboyd/testingFiles/v2/symlink v5 reverse with space" "/Users/eleanorboyd/testingFiles/v2/symlink_v6" ln -s "/Users/eleanorboyd/testingFiles/v2/symlink_folder/target folder has spaces" "/Users/eleanorboyd/testingFiles/v2/symlink_v4"

in both it successfully discovered and run the tests. Could you send along your full python logs? And also confirm you are the most recent version of the extension (pre-release). Thanks

alanwilter commented 6 months ago

Hi, thanks for getting back.

First, I still can't add comments in https://github.com/microsoft/vscode-python/issues/22018

Second, I believe this issue https://github.com/microsoft/vscode-python/issues/23224 may be somehow related.

I'm using your cwd_specified.zip

The scenario with the issue is this, you must use Mac iCloud folder (I testes with ~/Download and couldn't reproduce the issue):

/Users/alan/Library/Mobile Documents/com~apple~CloudDocs/Projects/cwd_specified

code "/Users/alan/Library/Mobile Documents/com~apple~CloudDocs/Projects/cwd_specified"

Do cmd + shift + P and then Python: Select Interpreter : Create Virtual Environment... : Venv

You may Delete and Recreate, choose any python version you like.

In a Terminal (be sure to see .venv), install pytest:

pip install pytest

Go to Test Explorer, running all tests should be OK.

Now, to reproduce the issue I'm seeing:

I have in my home folder (/Users/alan/) this symlink:

Projects -> '/Users/alan/Library/Mobile Documents/com~apple~CloudDocs/Projects'

ln -s '/Users/alan/Library/Mobile Documents/com~apple~CloudDocs/Projects' ~/

Then:

code ~/Projects/cwd_specified/

You need to set up the Python Interpreter again, choose the one already created and go to Test Explorer.

Try to run the tests, nothing happens.

eleanorjboyd commented 6 months ago

Aha! I think I have found it. My edit to support symlinks only checked to see if the cwd was a symlink which does not work if the child directory is a cwd. So in your example the symlink is the parent directory of the workspace cwd (where you open the workspace on cwd_specified) which means my added code is not catching it.

const resolvedPath = fs.realpathSync(cwd);
if (stats.isSymbolicLink() // this will be false for the cwd if it is a child of a symlink

working on a fix now! Thank you for all your help!! Fingers crossed this fixes the bug.

eleanorjboyd commented 6 months ago

Hello! I have put in a fix for this issue and it should now be working! If you could try it on the newest version of the python extension nightly pre-release that would be great so we know if it works!

Happy coding!

eleanorjboyd commented 6 months ago

So sorry this is long, wrote steps best I could and hopefully this will help!! Let me know if you have any questions

  1. create a folder nested like so '/Users/eleanorboyd/testingFiles/v2/weird folder~name/general_folder'
  2. inside general_folder create a python test file like test_ex.py
  3. add a test inside like so
    def test_random():
    assert True;
  4. open vscode to general_folder
  5. create a venv
  6. install pytest (python -m pip install pytest)
  7. CLOSE vscode
  8. go to your terminal
  9. create a symlink like so: ln -s '/Users/eleanorboyd/testingFiles/v2/weird folder~name' ~/weird-folder-link
  10. now open vscode at 'weird-folder-link/general_folder' like code-insiders ~/weird-folder-link/general_folder
  11. open the file test_ex.py copy the full path, verify that it is the symlink path so weird-folder-link
  12. click on the test explorer tab
  13. select pytest and root dir (".")
  14. make sure the test test_random shows up
  15. on the test explorer use the "go to test" button to the side of the test_random
  16. make sure that the file it leads you to is the symlink path so weird-folder-link
  17. run tests, make sure they pass and the icon for the test in the explorer turns green
alanwilter commented 6 months ago

@eleanorjboyd I can finally confirm that it's all working as expected at least in VSCode:

Version: 1.89.0
Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd
Date: 2024-05-01T02:10:13.496Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0

Many thanks!

eleanorjboyd commented 6 months ago

So pumped to hear this! Thanks for all the responses / engagement to get this fix