mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Merge pull request #4675 from inspec/mj/hab1101
Get artifact/habitat starting tests on both Windows and Linux
This commit is contained in:
commit
549e3c196e
4 changed files with 34 additions and 8 deletions
|
@ -3,4 +3,4 @@
|
|||
set -ueo pipefail
|
||||
|
||||
hab origin key import < "$HAB_CI_KEY"
|
||||
hab pkg install --binlink "./results/${pkg_artifact:?is undefined}"
|
||||
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
|
||||
|
|
|
@ -12,7 +12,14 @@ $Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'
|
|||
Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize
|
||||
|
||||
Write-Host "--- Installing the version of Habitat required"
|
||||
Install-Habitat --version 0.85.0.20190916
|
||||
$hab_version = (hab --version)
|
||||
$hab_minor_version = $hab_version.split('.')[1]
|
||||
if ( -not $? -Or $hab_minor_version -lt 85 ) {
|
||||
Install-Habitat --version 0.85.0.20190916
|
||||
} else {
|
||||
Write-Host ":habicat: I think I have the version I need to build."
|
||||
}
|
||||
|
||||
|
||||
Write-Host "--- Generating fake origin key"
|
||||
hab origin key generate $env:HAB_ORIGIN
|
||||
|
@ -21,17 +28,19 @@ Write-Host "--- Building $Plan"
|
|||
$project_root = "$(git rev-parse --show-toplevel)"
|
||||
Set-Location $project_root
|
||||
|
||||
$env:DO_CHECK=$true; hab pkg build . -D
|
||||
$env:DO_CHECK=$true; hab pkg build .
|
||||
if (-not $?) { throw "unable to build" }
|
||||
|
||||
. $project_root/results/last_build.ps1
|
||||
if (-not $?) { throw "unable to determine details about this build" }
|
||||
|
||||
Write-Host "--- Installing $pkg_ident/$pkg_artifact"
|
||||
hab pkg install $project_root/results/$pkg_artifact
|
||||
hab pkg install -b $project_root/results/$pkg_artifact
|
||||
if (-not $?) { throw "unable to install this build" }
|
||||
|
||||
Write-Host "+++ Testing $Plan"
|
||||
|
||||
$env:PATH = "C:\hab\bin;$env:PATH"
|
||||
Push-Location $project_root/test/artifact
|
||||
rake
|
||||
if (-not $?) { throw "rake failed" }
|
||||
|
|
|
@ -25,6 +25,7 @@ echo "--- Sourcing 'results/last_build.sh'"
|
|||
if [ -f ./results/last_build.env ]; then
|
||||
. ./results/last_build.env
|
||||
export pkg_artifact
|
||||
export project_root
|
||||
fi
|
||||
|
||||
echo "+++ Installing ${pkg_ident:?is undefined}"
|
||||
|
@ -35,6 +36,10 @@ HSI="$project_root"/.expeditor/buildkite/artifact.habitat.install.sh
|
|||
sudo -E "$HSI"
|
||||
|
||||
echo "+++ Testing $PLAN"
|
||||
|
||||
PATH="/hab/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
pushd "$project_root/test/artifact"
|
||||
rake
|
||||
hab pkg exec core/ruby rake
|
||||
popd
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
require "minitest/autorun"
|
||||
|
||||
class TestArtifactDetect < Minitest::Test
|
||||
def test_inspec_exists_linux
|
||||
skip if windows?
|
||||
refute_match(/no inspec/, `/usr/bin/which inspec`)
|
||||
end
|
||||
|
||||
def test_inspec_exists_windows
|
||||
skip unless windows?
|
||||
assert_match(/inspec.bat/, `Get-Command inspec`)
|
||||
end
|
||||
|
||||
def test_detect
|
||||
exit = nil
|
||||
out, err = capture_subprocess_io do
|
||||
assert system("inspec detect --no-color")
|
||||
exit = system("inspec detect --no-color")
|
||||
end
|
||||
|
||||
assert_match %r{/Platform Details/}, out
|
||||
assert_empty err
|
||||
assert_empty err.sub(/#< CLIXML\n/, "")
|
||||
assert_match(/Platform Details/, out)
|
||||
assert exit
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue