forked from endless-sky/endless-sky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_parse.ps1
51 lines (48 loc) · 1.79 KB
/
test_parse.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
# PowerShell test script (for testing on Windows CI services)
param(
[Parameter(Mandatory=$true, HelpMessage="Path to the Endless Sky executable file")]
$EndlessSky #The input binary to execute
)
$av = !!$env:APPVEYOR;
$testName = "Parse Game Data";
if ($av)
{
Add-AppveyorTest -Name $testName -Framework 'ES' -FileName $EndlessSky -Outcome Running;
}
# Remove any existing error files first.
$FILEDIR = if ($IsWindows) { "$env:APPDATA\endless-sky\" } `
else { "$env:HOME/.local/share/endless-sky" };
$ERR_FILE = Join-Path -Path $FILEDIR -ChildPath "errors.txt";
if (Test-Path -Path $ERR_FILE) { Remove-Item -Path $ERR_FILE; }
# Parse the game data files
$start = $(Get-Date);
$p = Start-Process -FilePath $EndlessSky -ArgumentList '-p' -Wait -PassThru;
$dur = New-TimeSpan -Start $start -End $(Get-Date);
# Assert there is no "errors.txt" file
if (Test-Path -Path "$ERR_FILE")
{
$err_msg = "Assertion failed: parsing files created file 'errors.txt' in $FILEDIR";
if ($av)
{
$messages = @();
$(Get-Content -Path $ERR_FILE -Raw).Split("`n") | ForEach-Object `
{
if ($_.StartsWith(' ') -or $_.StartsWith('file'))
{ $messages[-1] += "`n$_"; }
elseif ($_) { $messages += $_; }
}
Update-AppveyorTest -Name $testName -Framework 'ES' -FileName $EndlessSky `
-Outcome Failed -Duration $dur.TotalMilliseconds -ErrorMessage $err_msg `
-StdErr ($messages -Join "`n`n");
Push-AppveyorArtifact (Resolve-Path -Path $ERR_FILE -Relative)
}
Write-Error -Message $err_msg -Category ParserError;
$host.SetShouldExit(1);
}
elseif ($av)
{
Update-AppveyorTest -Name $testName -Framework 'ES' `
-FileName $EndlessSky -Outcome Passed -Duration $dur.TotalMilliseconds;
}
else { Write-Host "No data-parsing errors were encountered"; }
$host.SetShouldExit($p.ExitCode);