run through formatter

rename pre-commit to run

remove num and log parameters
This commit is contained in:
onyx-and-iris 2025-06-06 13:49:35 +01:00
parent 0f68a2373d
commit a0a2c72634
4 changed files with 77 additions and 123 deletions

View File

@ -90,17 +90,17 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
Context 'Recorder' -Skip:$ifBasic { Context 'Recorder' -Skip:$ifBasic {
It "Should set and get Recorder.A3" { It 'Should set and get Recorder.A3' {
$vmr.recorder.A3 = $value $vmr.recorder.A3 = $value
$vmr.recorder.A3 | Should -Be $expected $vmr.recorder.A3 | Should -Be $expected
} }
It "Should set and get Recorder.B1" { It 'Should set and get Recorder.B1' {
$vmr.recorder.B1 = $value $vmr.recorder.B1 = $value
$vmr.recorder.B1 | Should -Be $expected $vmr.recorder.B1 | Should -Be $expected
} }
It "Should set and get Recorder.loop" { It 'Should set and get Recorder.loop' {
$vmr.recorder.loop = $value $vmr.recorder.loop = $value
} }
} }
@ -248,8 +248,8 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Index = $phys_in }, @{ Index = $virt_in } @{ Index = $phys_in }, @{ Index = $virt_in }
) { ) {
It "Should set Strip[$index].Label" -ForEach @( It "Should set Strip[$index].Label" -ForEach @(
@{ Value = "test0"; Expected = "test0" } @{ Value = 'test0'; Expected = 'test0' }
@{ Value = "test1"; Expected = "test1" } @{ Value = 'test1'; Expected = 'test1' }
) { ) {
$vmr.strip[$index].label = $value $vmr.strip[$index].label = $value
$vmr.strip[$index].label | Should -Be $expected $vmr.strip[$index].label | Should -Be $expected
@ -260,8 +260,8 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Index = $phys_out }, @{ Index = $virt_out } @{ Index = $phys_out }, @{ Index = $virt_out }
) { ) {
It "Should set Bus[$index].Label" -ForEach @( It "Should set Bus[$index].Label" -ForEach @(
@{ Value = "test0"; Expected = "test0" } @{ Value = 'test0'; Expected = 'test0' }
@{ Value = "test1"; Expected = "test1" } @{ Value = 'test1'; Expected = 'test1' }
) { ) {
$vmr.bus[$index].label = $value $vmr.bus[$index].label = $value
$vmr.bus[$index].label | Should -Be $expected $vmr.bus[$index].label | Should -Be $expected
@ -273,7 +273,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
) { ) {
Context 'instream' { Context 'instream' {
Context 'ip' -ForEach @( Context 'ip' -ForEach @(
@{ Value = "0.0.0.0"; Expected = "0.0.0.0" } @{ Value = '0.0.0.0'; Expected = '0.0.0.0' }
) { ) {
It "Should set vban.instream[$index].name to $value" { It "Should set vban.instream[$index].name to $value" {
$vmr.vban.instream[$index].ip = $value $vmr.vban.instream[$index].ip = $value
@ -284,7 +284,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
Context 'outstream' { Context 'outstream' {
Context 'ip' -ForEach @( Context 'ip' -ForEach @(
@{ Value = "0.0.0.0"; Expected = "0.0.0.0" } @{ Value = '0.0.0.0'; Expected = '0.0.0.0' }
) { ) {
It "Should set vban.outstream[$index].name to $value" { It "Should set vban.outstream[$index].name to $value" {
$vmr.vban.outstream[$index].ip = $value $vmr.vban.outstream[$index].ip = $value

View File

@ -29,7 +29,7 @@ Describe -Tag 'lower', -TestName 'All Lower Tests' {
@{ Index = $phys_in }, @{ Index = $virt_in } @{ Index = $phys_in }, @{ Index = $virt_in }
) { ) {
Context 'mute, mono, A1, B2' -ForEach @( Context 'mute, mono, A1, B2' -ForEach @(
@{ param = "mute" }, @{ param = "A1" } @{ param = 'mute' }, @{ param = 'A1' }
) { ) {
It "Should set Strip[0].$param to 1" { It "Should set Strip[0].$param to 1" {
Param_Set -PARAM "Strip[$index].$param" -VALUE $value Param_Set -PARAM "Strip[$index].$param" -VALUE $value

View File

@ -1,76 +0,0 @@
Param([String]$tag, [Int]$num = 1, [switch]$log, [string]$kind = "potato")
Import-Module .\lib\Voicemeeter.psm1
Function ParseLog {
Param([String]$logfile)
$summary_file = Join-Path $PSScriptRoot "_summary.log"
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
}
function main() {
try {
$vmr = Connect-Voicemeeter -Kind $kind
$vmr.command.RunMacrobuttons() # ensure macrobuttons is running before we begin
Write-Host "Running tests for $vmr"
# 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
# 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"
$logfile = Join-Path $PSScriptRoot "_results.log"
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
}
}
if ($log) { Parselog -logfile $logfile }
}
finally { Disconnect-Voicemeeter }
}
main

30
tests/run.ps1 Normal file
View File

@ -0,0 +1,30 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Target = "variablename")]
Param([String]$tag, [string]$kind = 'potato')
Import-Module .\lib\Voicemeeter.psm1
function main() {
try {
$vmr = Connect-Voicemeeter -Kind $kind
$vmr.command.RunMacrobuttons() # ensure macrobuttons is running before we begin
Write-Host "Running tests for $vmr"
# 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
# skip conditions by kind
$ifBasic = $vmr.kind.name -eq 'basic'
$ifNotPotato = $vmr.kind.name -ne 'potato'
Invoke-Pester -Tag $tag -PassThru | Out-Null
}
finally { Disconnect-Voicemeeter }
}
main