blob: 6eced2755cdb7eeb6676ac55e4c8a85452a75056 (
plain) (
blame)
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
|
param(
[string] $ProjectDir = $null,
[string] $UtilsDir = $null,
[string] $PythonDir = $null
)
$ErrorActionPreference = "Stop";
Set-PSDebug -Strict
function Invoke-Exe {
param(
[ScriptBlock] $Cmd,
[int[]] $AllowedExitCodes = @(0)
)
$backupErrorActionPreference = $script:ErrorActionPreference
$script:ErrorActionPreference = 'Continue'
try {
& $Cmd
if ($AllowedExitCodes -notcontains $LastExitCode) {
throw "External command failed with exit code ${LastExitCode}: $Cmd"
}
} finally {
$script:ErrorActionPreference = $backupErrorActionPreference
}
}
function Test-AppVeyor {
return Test-Path env:APPVEYOR
}
function Get-AppVeyorBuildDir {
return 'C:\Projects\build'
}
function Get-AppVeyorUtilsDir {
$configuration = $env:CONFIGURATION
return "$(Get-AppVeyorBuildDir)\utils\$configuration"
}
function Get-AppVeyorPythonDir {
$platform = $env:PLATFORM
if ($platform -eq 'x64') {
return 'C:\Python36-x64'
} else {
return 'C:\Python36'
}
}
function Set-AppVeyorDefaults {
$script:ProjectDir = $env:APPVEYOR_BUILD_FOLDER
$script:UtilsDir = Get-AppVeyorUtilsDir
$script:PythonDir = Get-AppVeyorPythonDir
}
function Run-ProjectTests {
param(
[Parameter(Mandatory=$true)]
[string] $ProjectDir,
[Parameter(Mandatory=$true)]
[string] $UtilsDir
)
$test_dir = "$ProjectDir\test"
cd $test_dir
Invoke-Exe { python.exe nist.py --path $UtilsDir --log nist.log }
Get-Content nist.log -Tail 5
Invoke-Exe { python.exe cavp.py --path $UtilsDir --log cavp.log }
Get-Content cavp.log -Tail 5
Invoke-Exe { python.exe nist.py --path $UtilsDir --log nist_boxes.log --boxes }
Get-Content nist_boxes.log -Tail 5
Invoke-Exe { python.exe cavp.py --path $UtilsDir --log cavp_boxes.log --boxes }
Get-Content cavp_boxes.log -Tail 5
Invoke-Exe { python.exe file.py --path $UtilsDir --log file.log }
Get-Content file.log -Tail 5
}
function Run-ProjectTestsAppVeyor {
if (Test-AppVeyor) {
Set-AppVeyorDefaults
$appveyor_cwd = pwd
}
try {
if ($script:PythonDir) {
$env:PATH = "${script:PythonDir};${env:PATH}"
}
Run-ProjectTests `
-ProjectDir $script:ProjectDir `
-UtilsDir $script:UtilsDir
} finally {
if (Test-AppVeyor) {
cd $appveyor_cwd
}
}
}
Run-ProjectTestsAppVeyor
|