From 0466ec287d7f87d3974bf02aba613d0072c9bb7c Mon Sep 17 00:00:00 2001 From: Pete Higgins Date: Fri, 4 Sep 2020 16:06:11 -0700 Subject: Fix habitat argument passing in Windows test script. Signed-off-by: Pete Higgins --- habitat/tests/test.pester.ps1 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/habitat/tests/test.pester.ps1 b/habitat/tests/test.pester.ps1 index a5f665c9de..56f31e9a2f 100644 --- a/habitat/tests/test.pester.ps1 +++ b/habitat/tests/test.pester.ps1 @@ -12,8 +12,21 @@ Describe "chef-infra-client" { $? | Should be $true } + <# + At some point hab's argument parsing changed and it started interpreting the trailing `--version` as being + an argument passed to hab instead of an argument to the command passed to `hab pkg exec`. + + Powershell 5.1 and 7 appear to differ in how they treat following arguments as well, such that these two + versions of the command fail in powershell 5.1 (which is currently what is running in the windows machines + in Buildkite) but pass in powershell 7 (which is currently what is running in a stock Windows 10 VM). + + $the_version = (hab pkg exec $PackageIdentifier chef-client.bat '--version' | Out-String).split(':')[1].Trim() + $the_version = (hab pkg exec $PackageIdentifier chef-client.bat --version | Out-String).split(':')[1].Trim() + + This version of the command passes in powershell 5.1 but fails in powershell 7. + #> It "is the expected version" { - $the_version = (hab pkg exec $PackageIdentifier chef-client.bat --version | Out-String).split(':')[1].Trim() + $the_version = (hab pkg exec $PackageIdentifier chef-client.bat -- --version | Out-String).split(':')[1].Trim() $the_version | Should be $PackageVersion } } @@ -52,4 +65,4 @@ Describe "chef-infra-client" { $? | Should be $true } } -} \ No newline at end of file +} -- cgit v1.2.1