2022-10-30 01:54:32 +01:00
|
|
|
Param([String]$tag, [Int]$num=1, [switch]$log, [string]$kind="potato")
|
|
|
|
Import-Module .\lib\Voicemeeter.psm1
|
2022-03-08 23:01:41 +00:00
|
|
|
|
|
|
|
Function ParseLog {
|
|
|
|
Param([String]$logfile)
|
2022-10-30 01:26:04 +00:00
|
|
|
$summary_file = Join-Path $PSScriptRoot "_summary.log"
|
2022-03-08 23:01:41 +00:00
|
|
|
if (Test-Path $summary_file) { Clear-Content $summary_file }
|
|
|
|
|
|
|
|
$PASSED_PATTERN = "^PassedCount\s+:\s(\d+)"
|
|
|
|
$FAILED_PATTERN = "^FailedCount\s+:\s(\d+)"
|
|
|
|
|
|
|
|
$DATA = @{
|
|
|
|
"passed" = 0
|
|
|
|
"failed" = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
ForEach ($line in `
|
|
|
|
$(Get-content -Path "${logfile}")) {
|
|
|
|
if ($line -match $PASSED_PATTERN) {
|
|
|
|
$DATA["passed"] += $Matches[1]
|
|
|
|
}
|
|
|
|
elseif ($line -match $FAILED_PATTERN) {
|
|
|
|
$DATA["failed"] += $Matches[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"=========================`n" + `
|
|
|
|
"$num tests run:`n" + `
|
|
|
|
"=========================" | Tee-Object -FilePath $summary_file -Append
|
|
|
|
$DATA | ForEach-Object { $_ } | Tee-Object -FilePath $summary_file -Append
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-27 21:20:51 +01:00
|
|
|
function main() {
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch ($kind) {
|
|
|
|
"basic" { $vmr = Get-RemoteBasic }
|
|
|
|
"banana" { $vmr = Get-RemoteBanana }
|
|
|
|
"potato" { $vmr = Get-RemotePotato }
|
|
|
|
}
|
|
|
|
Write-Host "Running tests for $vmr"
|
2022-03-08 23:01:41 +00:00
|
|
|
|
2022-10-27 21:20:51 +01:00
|
|
|
# test boundaries by kind
|
|
|
|
$phys_in = $vmr.kind.p_in - 1
|
|
|
|
$virt_in = $vmr.kind.p_in + $vmr.kind.v_in - 1
|
|
|
|
$phys_out = $vmr.kind.p_out - 1
|
|
|
|
$virt_out = $vmr.kind.p_out + $vmr.kind.v_out - 1
|
|
|
|
$vban_in = $vmr.kind.vban_in - 1
|
|
|
|
$vban_out = $vmr.kind.vban_out - 1
|
2022-03-08 23:01:41 +00:00
|
|
|
|
2022-10-27 21:20:51 +01:00
|
|
|
# skip conditions by kind
|
|
|
|
$ifBasic = $vmr.kind.name -eq "basic"
|
|
|
|
$ifBanana = $vmr.kind.name -eq "banana"
|
|
|
|
$ifPotato = $vmr.kind.name -eq "potato"
|
|
|
|
$ifNotBasic = $vmr.kind.name -ne "basic"
|
|
|
|
$ifNotBanana = $vmr.kind.name -ne "banana"
|
|
|
|
$ifNotPotato = $vmr.kind.name -ne "potato"
|
|
|
|
|
2022-10-30 01:26:04 +00:00
|
|
|
$logfile = Join-Path $PSScriptRoot "_results.log"
|
2022-10-27 21:20:51 +01:00
|
|
|
if (Test-Path $logfile) { Clear-Content $logfile }
|
|
|
|
|
|
|
|
1..$num | ForEach-Object {
|
|
|
|
if ($log) {
|
|
|
|
"Running test $_ of $num" | Tee-Object -FilePath $logfile -Append
|
|
|
|
Invoke-Pester -Tag $tag -PassThru | Tee-Object -FilePath $logfile -Append
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
"Running test $_ of $num"
|
|
|
|
Invoke-Pester -Tag $tag -PassThru
|
|
|
|
}
|
2022-03-08 23:01:41 +00:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:51 +01:00
|
|
|
if($log) { Parselog -logfile $logfile }
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
$vmr.Logout()
|
|
|
|
}
|
2022-03-08 23:01:41 +00:00
|
|
|
}
|
2022-10-27 21:20:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($MyInvocation.InvocationName -ne '.') { main }
|