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

Pester 4 RC, PowerShell Core regression: $PSVersionTable.PSVersion change #864

Closed
Jaykul opened this Issue Sep 6, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@Jaykul
Contributor

Jaykul commented Sep 6, 2017

When I Invoke-Pester on Pester 4.0.6rc on PowerShell v6.0.0-beta.5 Core (on Windows 10) a lot of tests are failing because of version comparisons. In PowerShell Core, $PSVersionTable.PSVersion is a System.Management.Automation.SemanticVersion and so these tests all threw an error in the Describe block because they can't compare versions:

  • Describing Analyzing coverage of a DSC configuration
  • Describing When calling Mock on an alias
  • Describing When calling Mock on existing cmdlet to handle pipelined input
  • Describing When calling Mock on cmdlet Used by Mock
  • Describing Dot Source Test

The error basically just says:

PSArgumentException: Cannot process argument because the value of argument "version" is not valid. Change the value of the "version" argument and run the operation again.
PSInvalidCastException: Cannot convert value "5.0.10586.122" to type "System.Management.Automation.SemanticVersion". Error: "Cannot process argument because the value of argument "version" is not valid. Change the value of the "version" argument and run the operation again."

Additionally, the following tests failed in the assertions, but with the same message about SemanticVersion casting ...

  • Describing Mocking Cmdlets with dynamic parameters
    [-] Allows calls to be made with dynamic parameters (including parameter filters)
  • Describing Mocking Cmdlets with dynamic parameters in a module
    [-] Allows calls to be made with dynamic parameters (including parameter filters)
  • Describing DynamicParam blocks in other scopes
    [-] Properly evaluates dynamic parameters when called from another scope
    [-] Properly evaluates dynamic parameters when called from another scope when the call is from a ValidateScript block
  • Describing Mocking Get-ItemProperty
    [-] Does not fail with NotImplementedException
  • Describing Mocking module-qualified calls
    [-] Calls the mock properly even if the call is module-qualified

And finally, this test also failed for a totally unrelated error, but is already mentioned in #838 ☹️

  • Describing ConvertTo-FailureLines
    [-] failed should produces correct message lines.

A total of 12 tests failed -- all tests pass running in PowerShell 5.1 on the same system.

@it-praktyk

This comment has been minimized.

Show comment
Hide comment
@it-praktyk

it-praktyk Sep 6, 2017

Contributor

@Jaykul, thank you for your report.

Could you test the code what you can find in the branch https://github.com/it-praktyk/Pester/tree/DevV4-1_Linux_compatibility_2?

Most of the issues are currently resolved.

Update 2017-09-7
Please test https://github.com/it-praktyk/Pester/tree/DevV4-1_Linux_compatibility_4.

Contributor

it-praktyk commented Sep 6, 2017

@Jaykul, thank you for your report.

Could you test the code what you can find in the branch https://github.com/it-praktyk/Pester/tree/DevV4-1_Linux_compatibility_2?

Most of the issues are currently resolved.

Update 2017-09-7
Please test https://github.com/it-praktyk/Pester/tree/DevV4-1_Linux_compatibility_4.

@it-praktyk

This comment has been minimized.

Show comment
Hide comment
@it-praktyk

it-praktyk Sep 6, 2017

Contributor

BTW, you didn't provide what version of PSCore and OS was used for your test.

Contributor

it-praktyk commented Sep 6, 2017

BTW, you didn't provide what version of PSCore and OS was used for your test.

@Jaykul

This comment has been minimized.

Show comment
Hide comment
@Jaykul

Jaykul Sep 7, 2017

Contributor

Updated OP. It was beta 5 (I thought I was on b6, but wasn't) on Windows

Contributor

Jaykul commented Sep 7, 2017

Updated OP. It was beta 5 (I thought I was on b6, but wasn't) on Windows

@it-praktyk

This comment has been minimized.

Show comment
Hide comment
@it-praktyk

it-praktyk Nov 1, 2017

Contributor

Currently, the pull request #925 wait for merging so I assume that we can close this issue.

Contributor

it-praktyk commented Nov 1, 2017

Currently, the pull request #925 wait for merging so I assume that we can close this issue.

@it-praktyk it-praktyk closed this Nov 1, 2017

@Jaykul

This comment has been minimized.

Show comment
Hide comment
@Jaykul

Jaykul Nov 1, 2017

Contributor

Normally, one doesn't close issues before merging the PR.
Instead, you mention the issue as fixed in the PR, and when you merge it, the issues get closed.

Otherwise, if the PR doesn't get merged, the issue will NEVER be fixed. And I have to point out: there are open PRs in this project from 2014...

Contributor

Jaykul commented Nov 1, 2017

Normally, one doesn't close issues before merging the PR.
Instead, you mention the issue as fixed in the PR, and when you merge it, the issues get closed.

Otherwise, if the PR doesn't get merged, the issue will NEVER be fixed. And I have to point out: there are open PRs in this project from 2014...

@it-praktyk

This comment has been minimized.

Show comment
Hide comment
@it-praktyk

it-praktyk Nov 1, 2017

Contributor

I'm reopening the issue. I hope that it will you feel better.

Contributor

it-praktyk commented Nov 1, 2017

I'm reopening the issue. I hope that it will you feel better.

@it-praktyk it-praktyk reopened this Nov 1, 2017

@aaronpowell

This comment has been minimized.

Show comment
Hide comment
@aaronpowell

aaronpowell Nov 9, 2017

I just hit this same issue in adding Linux support to a module of mine (aaronpowell/ps-nvm#35).

Digging through it I came to find that the problem was caused by this line in Mock.ps1:

if ($PSVersionTable.PSVersion -ge '5.0.10586.122')

Changing it to

if ('5.0.10586.122' -lt $PSVersionTable.PSVersion)

From the branch above has seen it working now.

aaronpowell commented Nov 9, 2017

I just hit this same issue in adding Linux support to a module of mine (aaronpowell/ps-nvm#35).

Digging through it I came to find that the problem was caused by this line in Mock.ps1:

if ($PSVersionTable.PSVersion -ge '5.0.10586.122')

Changing it to

if ('5.0.10586.122' -lt $PSVersionTable.PSVersion)

From the branch above has seen it working now.

@it-praktyk

This comment has been minimized.

Show comment
Hide comment
@it-praktyk

it-praktyk Nov 11, 2017

Contributor

Fixed by #925

Contributor

it-praktyk commented Nov 11, 2017

Fixed by #925

@it-praktyk it-praktyk closed this Nov 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment