Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-Pester fails due to missing HelperFunctions since Pester 5.2.0-beta1 #1921

Closed
fawohlsc opened this issue Apr 27, 2021 · 2 comments · Fixed by #1925
Closed

Invoke-Pester fails due to missing HelperFunctions since Pester 5.2.0-beta1 #1921

fawohlsc opened this issue Apr 27, 2021 · 2 comments · Fixed by #1925
Milestone

Comments

@fawohlsc
Copy link

fawohlsc commented Apr 27, 2021

General summary of the issue

Invoke-Pester fails due to missing HelperFunctions since Pester 5.2.0-beta1:

image

Describe your environment

Pester version : 5.2.0-beta1 C:\Users*username*\Documents\PowerShell\Modules\Pester\5.2.0\Pester.psm1
PowerShell version : 7.1.3
OS version : Microsoft Windows NT 10.0.19042.0

Steps to reproduce

Code shared privately with @nohwnd.

Taken from stack trace:
image

Expected Behavior

Invoke-Pester to execute tests like it did in 5.2.0-alpha3.

Current Behavior

Invoke-Pester fails with error message shared above.

Possible Solution? (optional)

Currently not upgrading from 5.2.0-alpha3 as a workaround.

@nohwnd
Copy link
Member

nohwnd commented Apr 27, 2021

This seems to happen when running Pester from a module that has .psd1 dependency on other module that imports HelperFunctions via moduleToProcess dependency in their .psd1.

The module is some half-loaded state where we see it in Get-Module but can't invoke in it.

No exported commands seen there:

Binary     7.0.0.0               CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession…}
Script     0.0                   HelperFunctions                     
Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}

Needs a try catch around the clean up logic. And hopefully a test.

@nohwnd
Copy link
Member

nohwnd commented Apr 27, 2021

https://github.com/PowerShell/PowerShell/blob/658837323599ab1c7a81fe66fcd43f7420e4402b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs#L53 This is the source of the error. I guess I can check if the returned object has session state (if that is public on the module type) or just handle that type of exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants