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

The error produced by nested It blocks is obfuscated by an error in ConvertTo-FailureLines #510

Closed
alx9r opened this issue Apr 17, 2016 · 1 comment

Comments

@alx9r
Copy link
Member

alx9r commented Apr 17, 2016

Repro

Describe describe {
    It outer {
        It inner { $true }
    }
}

Results in this error:

image

Analysis

The originating block of code uses variable $count. That line was originally written as part of #426 in 77b84c9 like this:

Select-Object -First $count

I expected this to work because -First is typed as [int] and [int]$null evaluates to 0 in powershell. But these tests demonstrate that implicit casting of parameters does not behave in that manner nor consistently.

That line happens to have been changed in 344aee6 to this:

& $SafeCommands['Select-Object'] -First $count

That change is inconsequential to this problem, though, and this problem existed prior to that change in the original 77b84c9.

Fix

I have a working fix which is simply a matter of initializing $count. This restores the helpful output error message as follows:

image

I'll create a PR as soon as I (re)figure out the right way to do that.

@alx9r alx9r mentioned this issue Apr 17, 2016
@alx9r
Copy link
Member Author

alx9r commented Apr 17, 2016

This is already fixed as of 900d028.

@alx9r alx9r closed this as completed Apr 17, 2016
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

No branches or pull requests

1 participant