-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: nitin sanghi <[email protected]>
- Loading branch information
1 parent
b84037b
commit b28202e
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
param( | ||
[Parameter()] | ||
[string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows-default/1.0.0/20190812103929") | ||
) | ||
|
||
$PackageVersion = $PackageIdentifier.split('/')[2] | ||
|
||
Describe "chef-cli" { | ||
Context "chef-cli" { | ||
It "is an executable" { | ||
hab pkg exec $PackageIdentifier chef-cli.bat --version | ||
$? | 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-cli.bat -- --version | Out-String).split(':')[1].Trim() | ||
$the_version | Should be $PackageVersion | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
param ( | ||
[Parameter()] | ||
[string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") | ||
) | ||
|
||
# ensure Pester is available for test use | ||
if (-Not (Get-Module -ListAvailable -Name Pester)){ | ||
hab pkg install core/pester | ||
Import-Module "$(hab pkg path core/pester)\module\pester.psd1" | ||
} | ||
|
||
Write-Host "--- :fire: Smokish Pestering" | ||
# Pester the Package | ||
$__dir=(Get-Item $PSScriptRoot) | ||
$test_result = Invoke-Pester -Strict -PassThru -Script @{ | ||
Path = "$__dir/test.pester.ps1"; | ||
Parameters = @{PackageIdentifier=$PackageIdentifier} | ||
} | ||
if ($test_result.FailedCount -ne 0) { Exit $test_result.FailedCount } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
|
||
project_root="$(git rev-parse --show-toplevel)" | ||
pkg_ident="$1" | ||
|
||
# print error message followed by usage and exit | ||
error () { | ||
local message="$1" | ||
|
||
echo -e "\nERROR: ${message}\n" >&2 | ||
|
||
exit 1 | ||
} | ||
|
||
[[ -n "$pkg_ident" ]] || error 'no hab package identity provided' | ||
|
||
package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") | ||
|
||
cd "${project_root}" | ||
|
||
echo "--- :mag_right: Testing ${pkg_ident} executables" | ||
actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -- -v | sed -E 's/.*Version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
[[ "$package_version" = "$actual_version" ]] || error "chef-cli is not the expected version. Expected '$package_version', got '$actual_version'" | ||
|
||
echo "--- :Running rake" | ||
hab pkg exec "${pkg_ident}" rake unit |