99$ErrorActionPreference = " stop"
1010
1111if (! $IsCoreCLR ) {
12- Write-Error " End-to-end tests are only compatiable with Powershell Core"
12+ Write-Error " End-to-end tests are only compatible with PowerShell Core"
1313}
1414
1515# ##################################################################################################
@@ -42,7 +42,7 @@ function Wait-PathUpdatedAfter($Path, $Time, $Timeout) {
4242 $testScript = {
4343 (Test-Path - Path $Path ) -And ((Get-Item - Path $Path ).LastWriteTime -gt $Time )
4444 }
45- $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for '$Path ' to be updated after '$ ( $Time.ToString (" yyyy-MM-ddTHH:MM :ssZ" )) '" }
45+ $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for '$Path ' to be updated after '$ ( $Time.ToString (" yyyy-MM-ddTHH:mm :ssZ" )) '" }
4646 Wait-True - TestScript $testScript - TimeoutScript $timeoutScript - Timeout $Timeout
4747}
4848
@@ -65,7 +65,7 @@ function Wait-PathHasContent($Path, $Time, $Timeout) {
6565 $testScript = {
6666 (Test-Path - Path $Path ) -And ((Get-Content - Path $Path ).Length -gt 0 )
6767 }
68- $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for '$Path ' to have content after '$ ( $Time.ToString (" yyyy-MM-ddTHH:MM :ssZ" )) '" }
68+ $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for '$Path ' to have content after '$ ( $Time.ToString (" yyyy-MM-ddTHH:mm :ssZ" )) '" }
6969 Wait-True - TestScript $testScript - TimeoutScript $timeoutScript - Timeout $Timeout
7070}
7171
@@ -134,7 +134,7 @@ function Wait-SupervisorService($ServiceName, $Timeout = ($DefaultServiceTimeout
134134 }
135135 $status = (Invoke-WebRequest " $url " | ConvertFrom-Json ).process.state
136136 $status -eq " up"
137- } catch { $false } # We ignore 404s and other unsuccesful codes
137+ } catch { $false } # We ignore 404s and other unsuccessful codes
138138 }
139139 $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for Supervisor to start $ServiceName " }
140140 Wait-True - TestScript $testScript - TimeoutScript $timeoutScript - Timeout $Timeout
@@ -210,8 +210,9 @@ function New-TemporaryDirectory {
210210}
211211
212212function Restart-Supervisor {
213- if ($IsLinux ) {
214- pkill -- signal= HUP hab- launch
213+ if ($IsLinux -Or $IsMacOS ) {
214+ # macOS pkill does not support GNU --signal= syntax
215+ pkill - HUP hab- launch
215216 Start-Sleep 3 # wait for the signal to be processed
216217 } else {
217218 Stop-Process | Get-Process hab- sup
@@ -247,7 +248,7 @@ function Wait-Release($Ident, $Remote, $Timeout = ($DefaultServiceTimeout)) {
247248 $currentIdent = (Invoke-WebRequest " http://${Remote} :9631/services/$serviceName /default" | ConvertFrom-Json ).pkg.ident
248249 $currentIdent -eq $Ident
249250 }
250- $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for $Remote to Update to $Release " }
251+ $timeoutScript = { Write-Error " Timed out waiting $Timeout seconds for $Remote to update to $Ident " }
251252 Wait-True - TestScript $testScript - TimeoutScript $timeoutScript - Timeout $Timeout
252253}
253254
@@ -268,12 +269,16 @@ function Get-Leader($Remote, $ServiceGroup) {
268269}
269270
270271function Invoke-Build ($PackageName , $RefreshChannel ) {
271- $commandArgs = @ (" --reuse" )
272+ $commandArgs = @ ()
273+ if (! $IsMacOS ) {
274+ # --reuse is not compiled for macOS
275+ $commandArgs += @ (" --reuse" )
276+ }
272277 if ($RefreshChannel ) {
273278 $commandArgs += @ (" --refresh-channel" , $RefreshChannel )
274279 }
275280 hab pkg build test/ fixtures/ $PackageName $commandArgs
276- if ($IsLinux ) {
281+ if ($IsLinux -Or $IsMacOS ) {
277282 # This changes the format of last_build from `var=value` to `$var='value'`
278283 # so that powershell can parse and source the script
279284 Set-Content - Path " results/last_build.ps1" - Value " "
@@ -284,8 +289,15 @@ function Invoke-Build($PackageName, $RefreshChannel) {
284289Function Invoke-BuildAndInstall ($PackageName , $RefreshChannel ) {
285290 Invoke-Build @PSBoundParameters
286291 . ./ results/ last_build.ps1
287- hab pkg install ./ results/ $pkg_artifact
288- hab studio run " rm /hab/pkgs/$pkg_ident /hooks"
292+ if ($IsMacOS ) {
293+ # Use --ignore-install-hook because the install hook interpreter
294+ # (core/busybox-static) is not available for aarch64-darwin.
295+ hab pkg install -- ignore- install-hook ./ results/ $pkg_artifact
296+ # On macOS native studio there is no chroot, so no hook cleanup is needed.
297+ } else {
298+ hab pkg install ./ results/ $pkg_artifact
299+ hab studio run " rm /hab/pkgs/$pkg_ident /hooks"
300+ }
289301}
290302
291303function Stop-ComposeSupervisor ($Remote ) {
@@ -316,7 +328,14 @@ function Get-HabServicePID($PackageName) {
316328
317329# ##################################################################################################
318330
319- Import-Module (Join-Path - Path $ (hab pkg path core/ pester) module Pester.psd1)
331+ # Import Pester: prefer the hab-installed package, fall back to system-installed module
332+ $pesterPkgPath = $null
333+ try { $pesterPkgPath = hab pkg path core/ pester 2> $null } catch { $pesterPkgPath = $null }
334+ if ($pesterPkgPath -and (Test-Path $pesterPkgPath )) {
335+ Import-Module (Join-Path - Path $pesterPkgPath module Pester.psd1)
336+ } else {
337+ Import-Module Pester
338+ }
320339
321340if (Test-Path $TestName ) {
322341 $testPath = $TestName
0 commit comments