Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Revert powershell formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ince committed Oct 31, 2018
1 parent 5e567a0 commit 7ef5c6b
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions run_tests.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
$ErrorActionPreference = "Stop"
$BaseDir = $PSScriptRoot
$Password = "password"
$Port = 7699
$Python = "python.exe"
$TestArgs = $args

$ErrorBoltKitNotAvailable = 11
$ErrorCompilationFailed = 12
$ErrorServerCleanUpFailed = 18
$ErrorServerInstallFailed = 13
$ErrorServerConfigFailed = 14
$ErrorServerStartFailed = 15
$ErrorServerStopFailed = 16
$ErrorServerConfigurationError = 17
$ErrorTestsFailed = 199

trap
{
$ErrorActionPreference="Stop"
$BaseDir=$PSScriptRoot
$Password="password"
$Port=7699
$Python="python.exe"
$TestArgs=$args

$ErrorBoltKitNotAvailable=11
$ErrorCompilationFailed=12
$ErrorServerCleanUpFailed=18
$ErrorServerInstallFailed=13
$ErrorServerConfigFailed=14
$ErrorServerStartFailed=15
$ErrorServerStopFailed=16
$ErrorServerConfigurationError=17
$ErrorTestsFailed=199

trap {
Exit 1
}

Function CheckBoltKit()
{
Write-Host "Checking boltkit..."
& $Python -c "import boltkit" *> $null
If ($LASTEXITCODE -ne 0)
If ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorBoltKitNotAvailable
Expand All @@ -37,7 +36,7 @@ Function Compile()
{
Write-Host "Compiling..."
& cmd.exe /c "$BaseDir\make_debug.cmd" $env:SEABOLT_TOOLCHAIN
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorCompilationFailed
Expand Down Expand Up @@ -65,7 +64,7 @@ Function InstallServer($Target, $Version)
{
Write-Host "-- Installing server"
$Server = Invoke-Expression "neoctrl-install $Version $Target"
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerInstallFailed
Expand All @@ -75,8 +74,8 @@ Function InstallServer($Target, $Version)
Write-Host "-- Server installed at $Server"

Write-Host "-- Configuring server to listen on port $Port"
& neoctrl-configure "$Server" dbms.connector.bolt.listen_address = :$Port
if ($LASTEXITCODE -ne 0)
& neoctrl-configure "$Server" dbms.connector.bolt.listen_address=:$Port
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerConfigFailed
Expand All @@ -85,8 +84,8 @@ Function InstallServer($Target, $Version)
}

Write-Host "-- Configuring server to accept IPv6 connections"
& neoctrl-configure "$Server" dbms.connectors.default_listen_address = ::
if ($LASTEXITCODE -ne 0)
& neoctrl-configure "$Server" dbms.connectors.default_listen_address=::
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerConfigFailed
Expand All @@ -96,7 +95,7 @@ Function InstallServer($Target, $Version)

Write-Host "-- Setting initial password"
& neoctrl-set-initial-password "$Password" "$Server"
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerConfigFailed
Expand All @@ -112,7 +111,7 @@ Function StartServer($Server)
{
Write-Host "-- Starting server"
$BoltUri = Invoke-Expression "neoctrl-start $Server" | Select-String "^bolt:"
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerStartFailed
Expand All @@ -128,7 +127,7 @@ Function StopServer($Server)
{
Write-Host "-- Stopping server"
& neoctrl-stop $Server
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerStopFailed
Expand All @@ -149,10 +148,10 @@ Function RunTests($Version)
try
{
Write-Host "-- Checking server"
$env:BOLT_PASSWORD = $Password
$env:BOLT_PORT = $Port
$env:BOLT_PASSWORD=$Password
$env:BOLT_PORT=$Port
& $BaseDir\build\bin\Debug\seabolt-cli.exe debug "UNWIND range(1, 10000) AS n RETURN n"
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorServerConfigurationError
Expand All @@ -162,7 +161,7 @@ Function RunTests($Version)

Write-Host "-- Running tests"
& $BaseDir\build\bin\Debug\seabolt-test.exe $TestArgs
if ($LASTEXITCODE -ne 0)
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Code = $ErrorTestsFailed
Expand All @@ -179,13 +178,12 @@ Function RunTests($Version)

try
{
$env:NEO4J_CHILD_SCRIPT = "1"
$env:NEO4J_CHILD_SCRIPT="1"
CheckBoltKit
Compile

$Neo4jVersion = "-e 3.4"
If (Test-Path "env:NEOCTRLARGS")
{
If (Test-Path "env:NEOCTRLARGS") {
$Neo4jVersion = $env:NEOCTRLARGS
}

Expand All @@ -196,22 +194,22 @@ catch
$ErrorCode = 1
$ErrorMessage = $_.Exception.Message

If ($_.TargetObject.Code -and $_.TargetObject.Message)
If ( $_.TargetObject.Code -and $_.TargetObject.Message )
{
$ErrorCode = $_.TargetObject.Code
$ErrorMessage = $_.TargetObject.Message
}

If ($env:TEAMCITY_PROJECT_NAME)
If ( $env:TEAMCITY_PROJECT_NAME )
{
$CleanedErrorMessage = $ErrorMessage -replace "[^a-zA-Z0-9., ]"

Write-Host "##teamcity[buildProblem description='$( $CleanedErrorMessage )' identity='$( $ErrorCode )']"
Write-Host "##teamcity[buildStatus status='FAILURE' text='$( $CleanedErrorMessage )']"
Write-Host "##teamcity[buildProblem description='$($CleanedErrorMessage)' identity='$($ErrorCode)']"
Write-Host "##teamcity[buildStatus status='FAILURE' text='$($CleanedErrorMessage)']"
}
Else
{
Write-Host "$( $ErrorMessage ) [$( $ErrorCode )]"
Write-Host "$($ErrorMessage) [$($ErrorCode)]"
}

Exit $ErrorCode
Expand Down

0 comments on commit 7ef5c6b

Please sign in to comment.