Open AwaNoodle opened 9 years ago
Forgot to add: I modified the test to show a tree output just before it runs Get-NuGetPath. I got this result:
C:\USERS\ADMINISTRATOR\APPDATA\LOCAL\TEMP\1\83BFAD2E-F926-44C2-BD4F-19A856C7458D
ÀÄÄÄpackages
ÃÄÄÄNuGet.CommandLine.2.7.2
³ ÀÄÄÄtools
ÀÄÄÄNuGet.CommandLine.2.7.3
ÀÄÄÄtool
@AwaNoodle Hmmm, that's odd, that's a failure of this test..
https://github.com/lholman/OneBuild/blob/master/tests/CommonFunctions.Tests.ps1#L103
and this one..
https://github.com/lholman/OneBuild/blob/master/tests/CommonFunctions.Tests.ps1#L135
Both these tests use the Pester $TestDrive to add multiple versions of the associated .exe files to prove we always retrieve the latest if there are multiple versions restored in the OneBuild\Packages
folder, it would seem they are returning the lower, rather than the higher versions.
PS C:\Sandbox\OneBuild> Invoke-Pester .\tests -TestName "CommonFunctions.Get-NUnitPath"
PS C:\Sandbox\OneBuild> OneBuild.bat -task Invoke-OneBuildUnitTests
result in passed tests if you then run run Pester directly as above?Other thoughts
-Descending
parameter in the Sort-Object
isn't being adhered to on your system https://github.com/lholman/OneBuild/blob/master/tools/powershell/modules/CommonFunctions.psm1#L39I'm running Windows 2k8 with Powershell 4. I am running it through the ISE (64bit).
When I write out the exact same command by hand and create the files in the same structure by hand, I get the result I expect.
@AwaNoodle Could you copy the output in here as I asked above please?
Do you have another version of Pester in your path, can you copy the full output here of running the following? PS C:\Sandbox\OneBuild> Invoke-Pester .\tests -TestName "CommonFunctions.Get-NUnitPath"
Output from the test:
PS C:\Sandbox\OneBuild> Invoke-Pester .\tests -TestName "CommonFunctions.Get-NUnitPath"
Executing all tests in 'C:\Sandbox\OneBuild\tests' matching test name 'CommonFunctions.Get-NUnitPath'
Describing CommonFunctions.Get-NUnitPath
Context When there is more than one version of NuGet.Commandline installed
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/04/2015 14:10 packages
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/04/2015 14:10 NUnit.Runners.2.6.2
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages\NUnit.Runners.2.6.2
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/04/2015 14:10 tools
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages\NUnit.Runners.2.6.2\tools
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 10/04/2015 14:10 0 nunit-console.exe
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/04/2015 14:10 NUnit.Runners.2.6.3
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages\NUnit.Runners.2.6.3
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/04/2015 14:10 tools
Directory: C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages\NUnit.Runners.2.6.3\tools
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 10/04/2015 14:10 0 nunit-console.exe
[-] Should return the full path to to the highest version of NUnit.Runners found in the solution packages folder 193ms
Expected: {C:\Users\Administrator\AppData\Local\Temp\1\36230cbc-712e-45e1-ab7e-430773622a7d\packages\NUnit.Runners.2.6.3\tools\nunit-console.exe}, But was {C:\Users\Administrator\AppData\Local\Temp\1\36
230cbc-712e-45e1-ab7e-430773622a7d\packages\NUnit.Runners.2.6.2\tools\nunit-console.exe}
at line: 161 in C:\Sandbox\OneBuild\tests\CommonFunctions.Tests.ps1
Tests completed in 193ms
Passed: 0 Failed: 1
@AwaNoodle I can reproduce, I now get the same two tests failing using the ISE and running Pester directly too.
@lholman Did you try 32bit or 64bit? I've not tried 32bit yet.
@AwaNoodle Furthermore, it doesn't fail in a Powershell command prompt, only in the ISE.
Fails in 32 and 64bit ISE from what I can tell, can you expand more on "I write out the commands on the PS console to check how it works", do you mean console or ISE? The problem is the ISE here from what I can tell.
@AwaNoodle Found it...
c:\temp
, make sure you add nunit-console.exe
in to each tools folder
PS C:\temp\OneBuild> Get-ChildItem . -Recurse | Where-Object {$_.Name -like 'nunit-console.exe'} | Where-Object {$_.FullName -like '*nunit.runners*'} | Sort-Object $_.FullName -Descending | Select-Object FullName -First 1 | foreach {$_.FullName}
PS C:\temp\OneBuild> Get-ChildItem . -Recurse | Where-Object {$_.Name -like 'nunit-console.exe'} | Where-Object {$_.FullName -like '*nunit.runners*'} | Sort-Object $_.FullName -Descending | Select-Object FullName -First 1 | foreach {$_.FullName}
Observe the differences, it would seem that the ISE doesn't adhere to the combination of -Recurse
and Sort-Object -Descending
parameters
I guess it's a non-issue then :) Ok to close?
@AwaNoodle I imagine if we re-write the query it may work in both!?
Running the tests using Invoke-Pester rather than using the route via the OneBuild.bat gives me two failures, one for getting the latest nuget.exe path and one for the latest nunit path.
I am loading in the Pester module that is used by OneBuild:
From the OneBuild root, I am then running:
This gives me the two failures:
and
I don't see these if I run via the OneBuild.bat