System Details Output
### VSCode version: 1.49.0 e790b931385d72cf5669fcefc51cdf65990efa5d x64
### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
### PSES version: 2.3.0.0
### PowerShell version:
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This also appears with vs-code insiders and the 2020.9.0 extension ...
The issue is that the $psEditor.Workspace.OpenFile - which is called from various places - like PsEdit, changes the file name to lower case. This is usually just a cosmetic problem, but I have found a case were pester ran a script using its lower-cased name and the script failed because it tried to do a case sensitive replace on part of its own name.
@jhoneill can you give a particular example of where you've used this and what happened? There's not quite enough information here for me to work out what's going on and where the problem lies
@rjmholt I think we store ScriptFile's as all lower case in an OrderedDictionary on Mac/Windows. I've ran into it too, easiest way to repro is:
# In PSIC
New-Item Something.ps1 | Out-Null
psedit ./Something.ps1
And then look at the tab title.
I think it only happens when you haven't already opened the file at least once (so it's not in the workspace cache). I'm guessing the path is always lowercase in the request and if VSCode hasn't already cached some state for that file it'll take our word for it.
Sounds like our approach with surfacing the keys is wrong and they should be considered internal keys only, rather than something we expose somewhere.
Still, if I can get the example where it's caused a Pester issue in full detail, we'll be able to fix this in a much more reliable way than if I just guess where the issue is and claim it's solved.
Still, if I can get the example where it's caused a Pester issue in full detail, we'll be able to fix this in a much more reliable way than if I just guess where the issue is and claim it's solved.
It's working with the module from https://github.com/MethodsAndPractices/vsteam and the author has
a) A PS1 file for each command for each command function (e.g. Add-VSTeam.ps1)
b) A .Tests.PS1 file for each (e.g. Add-VSTeam.Tests.ps1) as the unit test for that command.
c) Lines in every unit-test to dot-source all the files needed for that command.
Describe "VSTeam" {
BeforeAll {
$sut = (Split-Path -Leaf $PSCommandPath).Replace(".Tests.", ".")
. "$PSScriptRoot/../../Source/Public/$sut"
So I
1) Open Add-VSTeam.Tests.ps1 from the PowerShell Window. It opens as add-vsteam.tests.ps1
2.) I click Debug tests in the VSCode editor.
Pester then runs add-vsteam.tests.ps1 and $PSCommandPath).Replace(".Tests.", ".") does not replace tests, because this replace() is case sensitive. The script tires to DOT source a file with .tests and everything fails.
I know I could fix this by using -replace (or making other changes) but this bit of design isn't under my control. I can work round it by not opening from the command line ... and everywhere else - on windows at least - it is just a cosmetic thing. I don't know what happens if the underlying OS has a case sensitive file system.
Thanks for the additional info @jhoneill
Most helpful comment
@rjmholt I think we store
ScriptFile's as all lower case in anOrderedDictionaryon Mac/Windows. I've ran into it too, easiest way to repro is:And then look at the tab title.
I think it only happens when you haven't already opened the file at least once (so it's not in the workspace cache). I'm guessing the path is always lowercase in the request and if VSCode hasn't already cached some state for that file it'll take our word for it.