aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/windows/appveyor/test.ps1
blob: 3eaefc827dfe31bc2e2a4c24aba2ae7de85ab3ba (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
function Restore-NativeCommandStream
{	<#
		.SYNOPSIS
		This CmdLet gathers multiple ErrorRecord objects and reconstructs outputs
		as a single line.

		.DESCRIPTION
		This CmdLet collects multiple ErrorRecord objects and emits one String
		object per line.
		.PARAMETER InputObject
		A object stream is required as an input.
		.PARAMETER Indent
		Indentation string.
	#>
	[CmdletBinding()]
	param(
		[Parameter(ValueFromPipeline=$true)]
		$InputObject
	)

	begin
	{	$LineRemainer = ""	}

	process
	{	if ($InputObject -is [System.Management.Automation.ErrorRecord])
		{	if ($InputObject.FullyQualifiedErrorId -eq "NativeCommandError")
			{	Write-Output $InputObject.ToString()		}
			elseif ($InputObject.FullyQualifiedErrorId -eq "NativeCommandErrorMessage")
			{	$NewLine = $LineRemainer + $InputObject.ToString()
				while (($NewLinePos = $NewLine.IndexOf("`n")) -ne -1)
				{	Write-Output $NewLine.Substring(0, $NewLinePos)
					$NewLine = $NewLine.Substring($NewLinePos + 1)
				}
				$LineRemainer = $NewLine
			}
		}
		elseif ($InputObject -is [String])
		{	Write-Output $InputObject		}
		else
		{	Write-Host "Unsupported object in pipeline stream"		}
	}

	end
	{	if ($LineRemainer -ne "")
		{	Write-Output $LineRemainer	}
	}
}

Write-Host "Run testsuites..." -ForegroundColor Yellow
cd "$($env:APPVEYOR_BUILD_FOLDER)\testsuite"
# Use a MinGW compatible path
$env:GHDL="$($env:GHDL_PREFIX_DIR)/bin/ghdl.exe"
$env:GHWDUMP="$($env:GHDL_PREFIX_DIR)/bin/ghwdump.exe"

# Exit status
$Err = 0

# =============================================================================
$TestFramework =  "GNA"
Write-Host "Running GNA tests..." -ForegroundColor Yellow
cd gna

$Directories = dir -Directory *
foreach ($Directory in $Directories)
{	$TestName = "GNA test: {0}" -f $Directory.Name
	$FileName = $Directory.Name

	Write-Host $TestName -ForegroundColor Yellow
	cd $Directory
	Add-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Running
	$start = Get-Date
	c:\msys64\usr\bin\bash.exe -c "./testsuite.sh" 2>&1 | Restore-NativeCommandStream | %{ "$_" }
	$end = Get-Date
	$TotalMilliseconds = ($end - $start).TotalMilliseconds
	if ($LastExitCode -eq 0)
	{ Write-Host "PASSED" -ForegroundColor Green
		Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Passed -Duration $TotalMilliseconds
	}
	else
	{	Write-Host "FAILED" -ForegroundColor Red
		Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Failed -Duration $TotalMilliseconds
		$Err = 1
	}
}
cd ..\..

# =============================================================================
$TestFramework =  "VESTS"
Write-Host "Running VESTS tests..." -ForegroundColor Yellow

cd vests

$TestName = "VESTS test:" # {0}" -f $Directory
$FileName = "VESTS" #$Directory

Write-Host $TestName -ForegroundColor Yellow
# Disable vests.  It works but takes ~20 min
if ($true)
{	Add-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Skipped
	$start = Get-Date
}
else
{	Add-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Running
	$start = Get-Date
	c:\msys64\usr\bin\bash.exe -c "./testsuite.sh" 2>&1 | Restore-NativeCommandStream | %{ "$_" }
	$end = Get-Date
	$TotalMilliseconds = ($end - $start).TotalMilliseconds
	if ($LastExitCode -eq 0)
	{ Write-Host "PASSED" -ForegroundColor Green
		Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Passed -Duration $TotalMilliseconds
	}
	else
	{	Write-Host "FAILED" -ForegroundColor Red
		Update-AppveyorTest -Name $TestName -Framework $TestFramework -FileName $FileName -Outcome Failed -Duration $TotalMilliseconds
		$Err = 1
	}
	cd ..
}

# =============================================================================
cd $env:APPVEYOR_BUILD_FOLDER
exit $Err