-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqfValidate.ps1
65 lines (58 loc) · 1.87 KB
/
sqfValidate.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
$testfolder = $args[0]
if([string]::IsNullOrEmpty($testfolder)) {
Write-Error "[ACTION ERROR] Didn't specified testfolder..."
Exit -1
}
if(! (Test-Path ($testfolder))) {
Write-Error "[ACTION ERROR] Folder doesn't exist..."
Exit -1
}
$sqfVm = "$PSScriptRoot\sqfvm\SQF-VM - Win64 - x64\sqfvm.exe"
if(! (Test-Path ($sqfVm))) {
$url = "https://github.com/SQFvm/vm/releases/download/1.3.2-RC1/1.3.2.RC1-Win64-x64.zip"
$temp = "$PSScriptRoot\sqfvm.zip"
Invoke-WebRequest -Uri $url -OutFile $temp
Expand-Archive -LiteralPath $temp -DestinationPath "$PSScriptRoot\sqfvm"
Remove-Item -path $temp
Write-Output "Extracted to $sqfvm"
}
else
{
Write-Output "SqfVm found successful"
}
$sqfFiles = Get-ChildItem -Path "$testfolder\*.sqf" -Recurse -Force
$configFiles = Get-ChildItem -Path "$testfolder\*.hpp" -Recurse -Force
$testFiles = $sqfFiles + $configFiles
#Write-Output $sqfFiles
$failed = $false;
$errorCount = 0;
foreach ($file in $testFiles) {
Write-Output "Testing file $file"
$vm = New-Object System.Diagnostics.ProcessStartInfo
$vm.FileName = $sqfVm
$vm.Arguments = "-a --no-execute-print --parse-only --load $testfolder -i $file --disable-macro-warnings"
$vm.UseShellExecute = $false
$vm.RedirectStandardError = $true
$vm.RedirectStandardOutput = $true
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $vm
$process.Start() > $null
$process.WaitForExit();
if($process.ExitCode -ne 0) {
$errorCount = $errorCount + 1;
$failed = $true
} else {
Write-Output "Passed!"
}
$output = $process.StandardError.ReadToEnd()
if($output) {
Write-Warning $output
}
}
if($failed) {
Write-Error "[TEST FAILED] Some scripts did not pass the test! Errors: $errorCount"
Exit -1
} else {
Write-Output "[TEST SUCCESSFUL] No errors where found!"
Exit 0
}