summaryrefslogtreecommitdiff
path: root/ci/test.ps1
blob: 449789b51d24880cf5d07b93d77bd07456380606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Set-StrictMode -Version Latest

$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$SourceDir = Split-Path (Split-Path (Get-Variable MyInvocation).Value.MyCommand.Path)
$BuildDir = Get-Location
$global:Success = $true

if ($Env:SKIP_TESTS) { exit }

# Ask ctest what it would run if we were to invoke it directly.  This lets
# us manage the test configuration in a single place (tests/CMakeLists.txt)
# instead of running clar here as well.  But it allows us to wrap our test
# harness with a leak checker like valgrind.  Append the option to write
# JUnit-style XML files.
function run_test {
	$TestName = $args[0]

	$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n"

	if (-Not ($TestCommand -match "(?ms).*\n^[0-9]*: Test command: ")) {
		echo "Could not find tests: $TestName"
		exit
	}

	$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n" -replace "(?ms).*\n^[0-9]*: Test command: ","" -replace "\n.*",""
	$TestCommand += " -r${BuildDir}\results_${TestName}.xml"

	Invoke-Expression $TestCommand
	if ($LastExitCode -ne 0) { $global:Success = $false }
}

Write-Host "##############################################################################"
Write-Host "## Configuring test environment"
Write-Host "##############################################################################"

if (-not $Env:SKIP_PROXY_TESTS -and -not $Env:SKIP_PROXY_SSL_TESTS) {
	Invoke-WebRequest -Method GET -Uri https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar -OutFile poxyproxy.jar

	Write-Host ""
	Write-Host "Starting HTTP proxy (Basic)..."
	javaw -jar poxyproxy.jar --port 8080 --ssl-port 8081 --ssl-keystore "$SourceDir/ci/proxy_keystore.jks" --ssl-keystore-password password --credentials foo:bar --auth-type basic --quiet

	Write-Host ""
	Write-Host "Starting HTTP proxy (NTLM)..."
	javaw -jar poxyproxy.jar --port 8090 --ssl-port 8091 --ssl-keystore "$SourceDir/ci/proxy_keystore.jks" --ssl-keystore-password password --credentials foo:bar --auth-type ntlm --quiet
}

if (-not $Env:SKIP_OFFLINE_TESTS) {
	Write-Host ""
	Write-Host "##############################################################################"
	Write-Host "## Running (offline) tests"
	Write-Host "##############################################################################"

	run_test offline
}

if ($Env:RUN_INVASIVE_TESTS) {
	Write-Host ""
	Write-Host "##############################################################################"
	Write-Host "## Running (invasive) tests"
	Write-Host "##############################################################################"

	$Env:GITTEST_INVASIVE_FS_SIZE=1
	$Env:GITTEST_INVASIVE_MEMORY=1
	$Env:GITTEST_INVASIVE_SPEED=1
	run_test invasive
	$Env:GITTEST_INVASIVE_FS_SIZE=$null
	$Env:GITTEST_INVASIVE_MEMORY=$null
	$Env:GITTEST_INVASIVE_SPEED=$null
}

if (-not $Env:SKIP_ONLINE_TESTS) {
	Write-Host ""
	Write-Host "##############################################################################"
	Write-Host "## Running (online) tests"
	Write-Host "##############################################################################"

	run_test online
}

if (-not $Env:SKIP_PROXY_TESTS) {
	# Test HTTP Basic authentication
	Write-Host ""
	Write-Host "Running proxy tests (Basic authentication)"
	Write-Host ""

	$Env:GITTEST_REMOTE_PROXY_HOST="localhost:8080"
	$Env:GITTEST_REMOTE_PROXY_USER="foo"
	$Env:GITTEST_REMOTE_PROXY_PASS="bar"
	run_test proxy

	# Test NTLM authentication
	Write-Host ""
	Write-Host "Running proxy tests (NTLM authentication)"
	Write-Host ""

	$Env:GITTEST_REMOTE_PROXY_HOST="localhost:8090"
	$Env:GITTEST_REMOTE_PROXY_USER="foo"
	$Env:GITTEST_REMOTE_PROXY_PASS="bar"
	run_test proxy

	$Env:GITTEST_REMOTE_PROXY_HOST=$null
	$Env:GITTEST_REMOTE_PROXY_USER=$null
	$Env:GITTEST_REMOTE_PROXY_PASS=$null
}

if (-not $Env:SKIP_SSL_PROXY_TESTS) {
	Write-Host ""
	Write-Host "Running proxy (SSL) tests"
	Write-Host ""

    $Env:GITTEST_REMOTE_PROXY_SCHEME="https"
	$Env:GITTEST_REMOTE_PROXY_HOST="localhost:8081"
	$Env:GITTEST_REMOTE_PROXY_USER="foo"
	$Env:GITTEST_REMOTE_PROXY_PASS="bar"
    $Env:GITTEST_REMOTE_PROXY_SELFSIGNED=1
    run_test proxy
    $Env:GITTEST_REMOTE_PROXY_SCHEME=$null
    $Env:GITTEST_REMOTE_PROXY_HOST=$null
    $Env:GITTEST_REMOTE_PROXY_USER=$null
    $Env:GITTEST_REMOTE_PROXY_PASS=$null
    $Env:GITTEST_REMOTE_PROXY_SELFSIGNED=$null
}

if (-not $Env:SKIP_PROXY_TESTS -and -not $Env:SKIP_SSL_PROXY_TESTS) {
	taskkill /F /IM javaw.exe
}

if (-Not $global:Success) { exit 1 }