-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnative-tests.ps1
74 lines (56 loc) · 2.28 KB
/
native-tests.ps1
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
$ErrorActionPreference = "Stop"
# This script should be primarily run from CI.
$pc = $args[0]
$ExeExt = $args[1]
$testFromLocalDirInstallation = $args[2]
function AbortIfCommandFailed
{
if ($LASTEXITCODE -ne 0) {
throw "Exit code is $LASTEXITCODE"
}
}
function Run-Tests
{
param(
$ProtocurlExec
)
Write-Output "====== Running tests using executable $ProtocurlExec ======"
Write-Output "=== Executable is runnable ==="
&"$ProtocurlExec" -h
AbortIfCommandFailed
Write-Output "=== Base scenario runs. protoc$ExeExt is found and used. protocurl-internal is found and used ==="
&"$ProtocurlExec" -I test/proto `
-f happyday.proto -i happyday.HappyDayRequest -o happyday.HappyDayResponse `
-u http://localhost:8080/happy-day/verify -d "includeReason: true"
AbortIfCommandFailed
Write-Output "=== GET request works without input ==="
&"$ProtocurlExec" -I test/proto `
-X GET -f happyday.proto -o happyday.HappyDayResponse `
-u http://localhost:8080/happy-day/verify
AbortIfCommandFailed
Write-Output "=== Using custom protoc and proto lib and global curl ==="
if (Test-Path my-protoc) {
Remove-Item my-protoc -Recurse -force
}
mkdir my-protoc
mkdir my-protoc/my-bin
Copy-Item "$pc/protocurl-internal/bin/protoc$ExeExt" -Destination my-protoc/my-bin/protoc$ExeExt
Copy-Item "$pc/protocurl-internal/include" -Destination my-protoc/my-protos -Recurse
Copy-Item "test/proto/*" -Destination my-protoc/my-protos -Recurse
&"$ProtocurlExec" -v --curl `
--protoc-path my-protoc/my-bin/protoc -I my-protoc/my-protos `
-f happyday.proto -i happyday.HappyDayRequest -o happyday.HappyDayResponse `
-u http://localhost:8080/happy-day/verify -d "includeReason: true"
AbortIfCommandFailed
}
Write-Output "========= Running native tests ========="
if ($testFromLocalDirInstallation -eq "localDirTests") {
Run-Tests("./$pc/bin/protocurl$ExeExt")
Write-Output "Installing protocurl into PATH and re-executing..."
$EnvPathSeparator = "$( [IO.Path]::PathSeparator )"
# ; on windows, : on unix
$Env:PATH += "$EnvPathSeparator$PWD/$pc/bin"
Write-Output "Path after installation: $Env:PATH"
}
Run-Tests("protocurl")
Write-Output "========= Native Tests successful. ========="