denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.5k stars 146 forks source link

CWD for tests should be switched in case of partial deno workspace #1113

Closed maheshbansod closed 6 months ago

maheshbansod commented 6 months ago

Describe the bug

To Reproduce

[Set up repo with deno enabled in a folder]

  1. Create a folder root
  2. Create another folder deno within it
  3. Add deno.json in deno folder with contents: {}
  4. Add .vscode/settings.json in the root folder with settings deno.enable as true, deno.enablePaths as ['./deno'], and deno.config as ./deno/deno.json (the settings needed to make the deno extension work with the deno folder)

[Add a test]

  1. Add a test in the deno folder that reads deno.json (from the same directory) i.e. use Deno.readTextFileSync('./deno.json')

[Observe bug]

  1. Run the test through VSCode

Expected behavior

The test code should successfully be able to read deno.json

Screenshots

If applicable, add screenshots to help explain your problem.

Versions

vscode: 1.86.2 deno: 1.42.1 extension: 3.37.1 (should be reproducible with any versions)

nayeemrmn commented 6 months ago

We probably won't do this, instead you should rewrite your tests to be cwd independent:

Deno.readTextFileSync(new URL('deno.json', import.meta.url))

The two choices for cwd are the workspace root (folder?) or the most local deno.json. The latter would disable running all of your workspace tests parallelly in one process. The location of the workspace root is a property of your project just as much as the deno.json's location, so it's a viable design.