Skip to content

Should-HaveType: Fails with The script failed due to call depth overflow #2828

Description

@johlju

Checklist

What is the issue?

In a few places in SqlServerDsc where we text for the stub types being returned i'm seeing this error. Only when we test the types of the SMO (Sql Management Objects) stubs.

In the gist link below I have added all the stubs so the problem can be easily reproduce. If I I remove all the other classes and just leave the properties with the normal types (string, int, etc.) the call to Should-HaveType do not return this error.

I have not yet removed one property/method at a time to see which one makes it fail. I can do that tomorrow. This can be a problem with the stubs, I haven't ruled that out.

Expected Behavior

Not fail with such error.

Steps To Reproduce

The reproducible code is so long so I put it in a public gist instead of directly in this issue:
https://gist.github.com/johlju/1989d84d03cc7c4135c5785cec0f0c58

  1. Save the content of the gist into a debug.tests.ps1
  2. Run the debug.tests.ps1 with Pester 6.0-rc4.

Describe your environment

Pester version     : 6.0.0-rc4 /Users/johlju/source/SqlServerDsc/output/RequiredModules/Pester/6.0.0/Pester.psm1        
PowerShell version : 7.5.4
OS version         : Unix 14.8.7

Possible Solution?

Not sure. But tt feels like it recursively going down the object tree, or it finds a property that points back to the same class so it starts looping. 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions