Current working location differs between Run and Debug
yukinobu opened this issue Β· comments
Recently I started using this vscode-adapter. I found its integration into VS Code's GUI so great. Thank you for developing the amazing software π
Description
The current working location differs depending whether do "Run Tests" or do "Debug Tests". You can see this difference with the Get-Location cmdlet. Since the current working location is different, the results of tests that depends location, such as tests including Import-Module cmdlet, will change between Run and Debug. I guess it is desirable that the test results are the same regardless of "Run Tests" or "Debug Tests".
Related Issue
Maybe this issue is related to issue #89. If you think this issue should merge to #89, feel free to do it.
NOTE: The cwd
configuration discussed in #89 not affected the behavior of this issue. The configuration I tried:
{
"powershell.cwd": "${workspaceFolder}",
"terminal.integrated.cwd": "${workspaceFolder}"
}
My environment
- Windows 10 21H2 [Version 10.0.19044.1586] (Japanese)
- Visual Studio Code 1.65.1
- Pester Tests v2022.2.0
- PowerShell 5.1.19041.1320
- Pester 5.3.1
- Visual Studio Code 1.65.1
Reproduction procedure
-
unzip attached powershell_pester_location_bug.zip
-
launch VS Code on
project_root_folder
folder -
move on "Testing" view and do "Debug Test"
-
stay on "Testing" view and do "Run Tests"
When I do "Run Tests", current working location seems to Microsoft VS Code
folder.
Expected behavior
I guess the behavior of "Debug Tests" is correct, but the behavior of "Run Tests" is incorrect. The current location should also be the project root when I do "Run Tests". This is the same behavior as Pester's Invoke-Pester
cmdlet.
Thanks for the detailed report! The starting directory is a little tricky especially if you are using a workspace with multiple project roots, but it makes sense for it at least to use the base. I never run into this problem becaues I use $PSScriptRoot
in my tests to define relative paths.
Thank you for your reply and advice! Also, thank you for adding to your Roadmap.
I agree that it's a good idea to use the $PSScriptRoot
variable. I plan to use it in the code I will write.
However, it's just my personal context, but there are some codes previously wrote which depends on the current location and I should maintain them. So it would be helpful for me if the location when "Run Tests" will be the same as when "Debug Tests".
Implemented in #119. It is an explicit setting, I wanted to avoid "magic" behavior with the terminal integrated console cwd hijacking it unexpectedly, and some more thinking needs to go into multi-root workspaces around this.
Sorry for the late reply.
I confirmed this issue has been solved in current version.
On Pester Tests v2022.3.3
, the Current working location is same between Run and Debug π