PowerShell / Operation-Validation-Framework

MIT License
225 stars 32 forks source link

Error Comparing Version Numbers #33

Closed MikeShepard closed 5 years ago

MikeShepard commented 6 years ago

The check for version 5 (in order to run Import-PowerShellDataFile) checks a version against an int. The implicit type conversion from 5 to version fails.

Current Behavior

Run Get-OperationValidation Result is an error: Could not compare "5.1.17134.228" to "5". Error: "Cannot convert value "5" to type "System.Version". Error: "Version string portion was too short or too long."" At C:\Users\mike_sh\Documents\WindowsPowerShell\Modules\operationvalidation\Public\Get-OperationValidation.ps1:223 char:21

Possible Solution

The relevant line is: if ($PSVersionTable.PSVersion -ge 5) { If it were changed to: if ($PSVersionTable.PSVersion -ge '5.0.0.0') { The implicit typecast (to [Version]) will succeed and the comparison would be consistent with the intent.

Steps to Reproduce (for bugs)

  1. Import the module
  2. Run "Get-OperationValidation

Your Environment

devblackops commented 6 years ago

Thanks @MikeShepard! Do you want to send in a PR to fix?

MikeShepard commented 6 years ago

Sure. It will have to be tonight, though.

On Thu, Oct 25, 2018 at 11:11 AM Brandon Olin notifications@github.com wrote:

Thanks @MikeShepard https://github.com/MikeShepard! Do you want to send in a PR to fix?

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/Operation-Validation-Framework/issues/33#issuecomment-433112576, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSNIi6B1JiXsRm7QauQ6wSxs-tBxjmsks5uoeLCgaJpZM4Xz_j2 .

MikeShepard commented 6 years ago

So...when I run the build.ps1 before making any changes. 16 tests fail.

When I run it after making the change, 11 tests fail. Any ideas?

I've attached the build output but I don't want to submit the PR until I know what's going on. :-)

On Thu, Oct 25, 2018 at 11:15 AM Mike Shepard mshepard70@gmail.com wrote:

Sure. It will have to be tonight, though.

On Thu, Oct 25, 2018 at 11:11 AM Brandon Olin notifications@github.com wrote:

Thanks @MikeShepard https://github.com/MikeShepard! Do you want to send in a PR to fix?

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/Operation-Validation-Framework/issues/33#issuecomment-433112576, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSNIi6B1JiXsRm7QauQ6wSxs-tBxjmsks5uoeLCgaJpZM4Xz_j2 .

MikeShepard commented 6 years ago

build_output.txt

devblackops commented 6 years ago

@MikeShepard Can you make sure you've pulled down the latest? It sounds like you're running into the bug fixed in #32 where if you have a ; at the beginning or end of $env:PSModulePath, then splitting it will result in $null entries.

MikeShepard commented 6 years ago

It was a fork of master created yesterday.

In Get-ModuleList, I have this: $pathsToSearch = $env:PSModulePath.Trim($script:pathSeparator).Split($script:pathSeparator)

which is from the commit after the fix to #32 (which just had ';')

MikeShepard commented 5 years ago

I definitely had the latest version (I forked the repo). I get the same errors (and some more) when I clone the repo from here ( https://github.com/PowerShell/Operation-Validation-Framework).

I'm seeing that the appveyor status shows that the builds are failing and see similar errors when I click through the badge.

On Thu, Oct 25, 2018 at 10:39 PM Brandon Olin notifications@github.com wrote:

@MikeShepard https://github.com/MikeShepard Can you make sure you've pulled down the latest? It sounds like you're running into the bug fixed in

32 https://github.com/PowerShell/Operation-Validation-Framework/pull/32

where if you have a ; at the beginning or end of $env:PSModulePath, then splitting it will result in $null entries.

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/Operation-Validation-Framework/issues/33#issuecomment-433276223, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSNIvABIqjxaDsI5feLYNLSzNngSB8dks5uooPrgaJpZM4Xz_j2 .

miketheitguy commented 5 years ago

https://github.com/PowerShell/Operation-Validation-Framework/pull/36

Hey all, I fixed this and @devblackops merged the PR today šŸ’Æ

MikeShepard commented 5 years ago

I saw that. Are the builds succeeding? I had a fix written, but couldn't get things to build and didn't get anywhere.

Glad that this is merged in, though.

On Fri, Feb 15, 2019 at 12:08 PM miketheitguy notifications@github.com wrote:

36 https://github.com/PowerShell/Operation-Validation-Framework/pull/36

Hey all, I fixed this and @devblackops https://github.com/devblackops merged the PR today šŸ’Æ

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/Operation-Validation-Framework/issues/33#issuecomment-464145029, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSNIgPyQ3Gl9W7R_W9D_S5FRNR0iG5sks5vNvepgaJpZM4Xz_j2 .

-- https://powershellstation.com

miketheitguy commented 5 years ago

Not sure! But Iā€™d love to try and tackle that next.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Mike Shepard notifications@github.com Sent: Friday, February 15, 2019 10:11 To: PowerShell/Operation-Validation-Framework Cc: miketheitguy; Comment Subject: Re: [PowerShell/Operation-Validation-Framework] Error Comparing Version Numbers (#33)

I saw that. Are the builds succeeding? I had a fix written, but couldn't get things to build and didn't get anywhere.

Glad that this is merged in, though.

On Fri, Feb 15, 2019 at 12:08 PM miketheitguy notifications@github.com wrote:

36 https://github.com/PowerShell/Operation-Validation-Framework/pull/36

Hey all, I fixed this and @devblackops https://github.com/devblackops merged the PR today šŸ’Æ

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/Operation-Validation-Framework/issues/33#issuecomment-464145029, or mute the thread https://github.com/notifications/unsubscribe-auth/AFSNIgPyQ3Gl9W7R_W9D_S5FRNR0iG5sks5vNvepgaJpZM4Xz_j2 .

-- https://powershellstation.com

ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FPowerShell%2FOperation-Validation-Framework%2Fissues%2F33%23issuecomment-464145982&data=02%7C01%7C%7C8561767227af421dc1b408d693710daa%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636858511095576898&sdata=cGSjEZwmaSieq82%2Bv4YTT1SnsDFDuwPS4aLvE85TFXI%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIhjbY9srJ7tqSDCx73pKMGbAcoiiOLdks5vNvhjgaJpZM4Xz_j2&data=02%7C01%7C%7C8561767227af421dc1b408d693710daa%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636858511095586903&sdata=v1Ut6wJZe7oijbU4PAD6HpLHl6a73OgOIP4zVcOllrw%3D&reserved=0.

devblackops commented 5 years ago

@MikeShepard The builds in AppVeyor work now. I asked the PowerShell team to allow Azure Pipelines on this project as well and I started wiring that up. Sadly, the builds fail there for some reason šŸ˜¦. Still some more troubleshooting to do.

MikeShepard commented 5 years ago

Fixed in #36