PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.69k stars 481 forks source link

Runtime Error when clicking Run Tests on a Pester test #871

Closed JohnLudlow closed 4 years ago

JohnLudlow commented 7 years ago

System Details


Name                           Value                       
----                           -----                       
PSVersion                      5.1.15063.296               
PSEdition                      Desktop                     
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}     
BuildVersion                   10.0.15063.296              
CLRVersion                     4.0.30319.42000             
WSManStackVersion              3.0                         
PSRemotingProtocolVersion      2.3                         
SerializationVersion           1.1.0.1                     

PS H:\src\tools\Automation\Modules\EsxVmMaker\test> code -v
PS H:\src\tools\Automation\Modules\EsxVmMaker\test> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      3      2      0

PS H:\src\tools\Automation\Modules\EsxVmMaker\test> code --list-extensions --show-versions
PS H:\src\tools\Automation\Modules\EsxVmMaker\test> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.296
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.296
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Output of code -v from a normal terminal:

1.13.0
376c52b955428d205459bea6619fc161fc8faacf

Output of code --list-extensions --show-versions from a normal terminal:

AlanWalk.markdown-toc@1.5.5
annsk.alignment@0.3.0
christian-kohler.path-intellisense@1.4.2
chrmarti.regex@0.1.0
DavidAnson.vscode-markdownlint@0.9.1
davidhouchin.whitespace-plus@0.0.4
donjayamanne.githistory@0.2.0
DougFinke.vscode-GetXrefLink@0.0.2
eamodio.gitlens@4.1.1
EditorConfig.EditorConfig@0.9.3
emmanuelbeziat.vscode-great-icons@2.1.7
Equinusocio.vsc-material-theme@0.0.15
gebilaoxiong.vscode-flatland-icon-theme@0.0.6
IBM.output-colorizer@0.1.1
Ionide.Ionide-FAKE@1.2.3
Ionide.Ionide-fsharp@2.26.1
Ionide.Ionide-Paket@1.6.3
jakob101.relativepathrefactor@0.8.0
jamesmaj.easy-icons@0.3.1
josa.markdown-table-formatter@0.2.2
joshbax.mdhelper@0.0.9
jprestidge.theme-material-theme@1.0.1
just4developments.testing-regex@0.0.2
miguel-savignano.ruby-symbols@0.1.5
ms-vscode.cpptools@0.11.4
ms-vscode.csharp@1.10.0
ms-vscode.PowerShell@1.3.2
ms-vsts.team@1.118.2
nestalk.preview-control-characters@0.0.1
nhoizey.gremlins@0.4.1
onecrayon.theme-quietlight-vsc@1.0.2
PeterJausovec.vscode-docker@0.0.16
qinjia.seti-icons@0.1.3
rebornix.Ruby@0.12.1
remcoros.startanyshell@0.3.1
robertohuertasm.vscode-icons@7.9.0
searKing.preview-vscode@1.1.5
steve8708.Align@0.2.0
teabyii.ayu@0.3.0
waderyan.gitblame@1.11.2
zgudino.editorconfig-vscode-snippet@0.2.0

Issue Description

I have a pester test:

$ModuleManifestName = 'ImageMaker.psd1'
$ModuleManifestPath = "$PSScriptRoot\..\$ModuleManifestName"

Describe 'Module Manifest Tests' {
    It 'Passes Test-ModuleManifest' {
        Test-ModuleManifest -Path $ModuleManifestPath
        $? | Should Be $true
    }
}

When I click the Run tests codelens link I get this error message box:

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!

Program: C:\WINDOWS\SysWOW64\windowspowershell\v1.0\PowerShell.exe

R6034

An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.

---------------------------
OK   
---------------------------

Attached Logs

PowerShellVsCodeLogs.zip

daviwil commented 7 years ago

Wow, that's surprising. This happens every time you try and run that test using "Run tests"? What happens when you use "Invoke-Pester " in the PowerShell Integrated Console, same result?

JohnLudlow commented 7 years ago

Grrr... It seemed like I could reproduce it reliably at first, but after trying it a few times it seems intermittent.

Initially, running the tests from Run tests showed the error, but I can't get that to fail anymore. Invoke-Pester from the integrated terminal did fail once, but I can't get that to fail anymore either. Running the test task (see configuration below) from the panel did work, but is now showing the error.

Test task config:

        {
            "taskName": "build",
            "isTestCommand": true,
            "command": "powershell",
            "options": {
                "cwd": "${workspaceRoot}"
            },
            "args": [
                "Invoke-Pester"
            ]
        }

I also tried from just a plain old powershell.exe and that seems to work.

Does the extension do anything interesting for the test task? If not, then this may not be an issue with the extension.

Thanks

daviwil commented 7 years ago

Nah, the tasks.json tasks are invoked purely in PowerShell, the extension isn't involved there.

Oh, you know what? I have seen this type of error before coming from the Integrated Terminal UI. There's a native library used called winpty which scrapes Windows console apps to surface them up to VS Code's HTML-based UI, I'll bet it's throwing an error. I've seen this before when running my own tasks in VS Code.

daviwil commented 7 years ago

But then again, this error says specifically that powershell.exe has an issue, so once again I'm not so sure :/

JohnLudlow commented 7 years ago

At the moment that's how it happens, so the Run tests thing was probably a red herring, and this might not be related to the PowerShell VSCode extension. I think I assumed it was the Run Tests codelens integration because that was the new thing in that last update.

TylerLeonhardt commented 4 years ago

@JohnLudlow this is a very old issue - have you still been experiencing this issue?

JohnLudlow commented 4 years ago

@TylerLeonhardt I agree it's old. In the meantime, I've moved companies and changed focus quite a bit so I no longer do the things I was trying to do originally, but a lot of the things above (like the version of PowerShell I use) aren't true anymore.

I can try to repro it though if you like.

TylerLeonhardt commented 4 years ago

If you don't mind, a repro attempt would be great. Otherwise, this issue will be automatically closed eventually.

JohnLudlow commented 4 years ago

@TylerLeonhardt Creating a new project with a plaster template, I can no longer reproduce this issue. My guess is that it was fixed as a side effect of other changes. I'd suggest you could close this issue, and if someone notices it again, it could be reopened.