Changeset View
Changeset View
Standalone View
Standalone View
contrib/teamcity/run-tests-windows.ps1
Show All 20 Lines | function check_help_version { | ||||
catch { | catch { | ||||
Write-Error $_ | Write-Error $_ | ||||
} | } | ||||
finally { | finally { | ||||
Stop-Process -name bitcoin-qt -Force -ErrorAction SilentlyContinue | Stop-Process -name bitcoin-qt -Force -ErrorAction SilentlyContinue | ||||
} | } | ||||
} | } | ||||
function New-TemporaryDirectory { | |||||
$parent = [System.IO.Path]::GetTempPath() | |||||
[string] $name = [System.Guid]::NewGuid() | |||||
$tempDir = New-Item -ItemType Directory -Path (Join-Path $parent $name) | |||||
return $tempDir.FullName | |||||
} | |||||
function check_bitcoind { | function check_bitcoind { | ||||
trap { | trap { | ||||
Stop-Process -name bitcoind -Force | Stop-Process -name bitcoind -Force | ||||
} | } | ||||
$datadir = New-TemporaryDirectory | |||||
$datadirArg = "-datadir=$datadir" | |||||
Write-Host "Launching bitcoind in the background" | Write-Host "Launching bitcoind in the background" | ||||
Start-Process -NoNewWindow .\bitcoind.exe "-noprinttoconsole" | Start-Process -NoNewWindow .\bitcoind.exe "-noprinttoconsole $datadirArg" | ||||
for($i=60; $i -gt 0; $i--) { | for($i=60; $i -gt 0; $i--) { | ||||
Start-Sleep -Seconds 1 | Start-Sleep -Seconds 1 | ||||
if(.\bitcoin-cli.exe help) { | if(.\bitcoin-cli.exe $datadirArg help) { | ||||
break | break | ||||
} | } | ||||
} | } | ||||
if($i -eq 0) { | if($i -eq 0) { | ||||
throw "Failed to start bitcoind" | throw "Failed to start bitcoind" | ||||
} | } | ||||
Write-Host "Stopping bitcoind" | Write-Host "Stopping bitcoind" | ||||
.\bitcoin-cli.exe stop | .\bitcoin-cli.exe $datadirArg stop | ||||
for($i=60; $i -gt 0; $i--) { | for($i=60; $i -gt 0; $i--) { | ||||
Start-Sleep -Seconds 1 | Start-Sleep -Seconds 1 | ||||
if(-Not (Get-Process -Name bitcoind -ErrorAction SilentlyContinue)) { | if(-Not (Get-Process -Name bitcoind -ErrorAction SilentlyContinue)) { | ||||
break | break | ||||
} | } | ||||
} | } | ||||
if($i -eq 0) { | if($i -eq 0) { | ||||
Show All 23 Lines |