From a0a2c726347b43ff14a37b49cb350c2dacbb6a12 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 6 Jun 2025 13:49:35 +0100 Subject: [PATCH] run through formatter rename pre-commit to run remove num and log parameters --- tests/higher.Tests.ps1 | 76 +++++++++++++++++++++--------------------- tests/lower.Tests.ps1 | 18 +++++----- tests/pre-commit.ps1 | 76 ------------------------------------------ tests/run.ps1 | 30 +++++++++++++++++ 4 files changed, 77 insertions(+), 123 deletions(-) delete mode 100644 tests/pre-commit.ps1 create mode 100644 tests/run.ps1 diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index 7fb3462..87f9397 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -2,10 +2,10 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Describe 'Bool tests' -ForEach @( @{ Value = $true; Expected = $true } @{ Value = $false; Expected = $false } - ){ + ) { Context 'Strip, one physical one virtual' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } - ){ + ) { It "Should set and get Strip[$index].Mute" { $vmr.strip[$index].mute = $value $vmr.strip[$index].mute | Should -Be $expected @@ -29,7 +29,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'physical only' -ForEach @( @{ Index = $phys_in } - ){ + ) { Context 'eq.{param}' -Skip:$ifNotPotato { It "Should set Strip[$index].EQ.On to $value" { $vmr.strip[$index].eq.on = $value @@ -40,7 +40,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'Bus, one physical one virtual' -ForEach @( @{ Index = $phys_out }, @{ Index = $virt_out } - ){ + ) { It "Should set and get Bus[$index].Eq.On" -Skip:$ifBasic { $vmr.bus[$index].eq.on = $value $vmr.bus[$index].eq.on | Should -Be $expected @@ -64,7 +64,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'Macrobutton' -ForEach @( @{ Index = 0 }, @{ Index = 69 } - ){ + ) { It "Should set and get macrobutton[$index] State" { $vmr.button[$index].state = $value $vmr.button[$index].state | Should -Be $expected @@ -73,7 +73,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'Vban instream' -ForEach @( @{ Index = $vban_in } - ){ + ) { It "Should set vban.instream[$index].on" { $vmr.vban.instream[$index].on = $value $vmr.vban.instream[$index].on | Should -Be $expected @@ -82,7 +82,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'Vban outstream' -ForEach @( @{ Index = $vban_out } - ){ + ) { It "Should set vban.outstream[$index].on" { $vmr.vban.outstream[$index].on = $value $vmr.vban.outstream[$index].on | Should -Be $expected @@ -90,17 +90,17 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } 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 | Should -Be $expected } - It "Should set and get Recorder.B1" { + It 'Should set and get Recorder.B1' { $vmr.recorder.B1 = $value $vmr.recorder.B1 | Should -Be $expected } - It "Should set and get Recorder.loop" { + It 'Should set and get Recorder.loop' { $vmr.recorder.loop = $value } } @@ -116,10 +116,10 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Describe 'Strip tests' { Context 'one physical, one virtual' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } - ){ + ) { Context 'gain' -ForEach @( @{ Value = 3.6; Expected = 3.6 }, @{ Value = -8.2; Expected = -8.2 } - ){ + ) { It "Should set Strip[$index].Gain to $value" { $vmr.strip[$index].gain = $value $vmr.strip[$index].gain | Should -Be $expected @@ -129,10 +129,10 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'physical only' -Skip:$ifBasic -ForEach @( @{ Index = $phys_in } - ){ + ) { Context 'comp, gate' -ForEach @( @{ Value = 8.3; Expected = 8.3 }, @{ Value = 5.1; Expected = 5.1 } - ){ + ) { It "Should set Strip[$index].Comp to $value" { $vmr.strip[$index].comp.knob = $value $vmr.strip[$index].comp.knob | Should -Be $expected @@ -146,7 +146,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'denoiser' -Skip:$ifNotPotato -ForEach @( @{ Value = 8.3; Expected = 8.3 }, @{ Value = 5.1; Expected = 5.1 } - ){ + ) { It "Should set Strip[$index].Denoiser to $value" { $vmr.strip[$index].denoiser.knob = $value $vmr.strip[$index].denoiser.knob | Should -Be $expected @@ -155,7 +155,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'comp.{param}' -Skip:$ifNotPotato -ForEach @( @{ Value = 8.3; Expected = 8.3 }, @{ Value = 5.1; Expected = 5.1 } - ){ + ) { It "Should set Strip[$index].Comp.Attack to $value" { $vmr.strip[$index].comp.attack = $value $vmr.strip[$index].comp.attack | Should -Be $expected @@ -164,7 +164,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'comp.{param}' -Skip:$ifNotPotato -ForEach @( @{ Value = 0.3; Expected = 0.3 }, @{ Value = 0.8; Expected = 0.8 } - ){ + ) { It "Should set Strip[$index].Comp.Knee to $value" { $vmr.strip[$index].comp.knee = $value $vmr.strip[$index].comp.knee | Should -Be $expected @@ -173,7 +173,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'gate.{param}' -Skip:$ifNotPotato -ForEach @( @{ Value = 103; Expected = 103 }, @{ Value = 3800; Expected = 3800 } - ){ + ) { It "Should set Strip[$index].Gate.BPSidechain to $value" { $vmr.strip[$index].gate.bpsidechain = $value $vmr.strip[$index].gate.bpsidechain | Should -Be $expected @@ -182,7 +182,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'gate.{param}' -Skip:$ifNotPotato -ForEach @( @{ Value = 0.3; Expected = 0.3 }, @{ Value = 5000; Expected = 5000 } - ){ + ) { It "Should set Strip[$index].Gate.Hold to $value" { $vmr.strip[$index].gate.hold = $value $vmr.strip[$index].gate.hold | Should -Be $expected @@ -194,10 +194,10 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Describe 'Bus tests' { Context 'one physical, one virtual' -ForEach @( @{ Index = $phys_out }, @{ Index = $virt_out } - ){ + ) { Context 'gain' -ForEach @( @{ Value = 5.2; Expected = 5.2 }, @{ Value = -38.2; Expected = -38.2 } - ){ + ) { It "Should set Bus[$index].Gain to $value" { $vmr.bus[$index].gain = $value $vmr.bus[$index].gain | Should -Be $expected @@ -209,11 +209,11 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Describe 'Int Tests' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } - ){ + ) { Context 'Strip, one physical, one virtual' -Skip:$ifBasic -ForEach @( @{ Value = 3; Expected = 3 } @{ Value = -6; Expected = -6 } - ){ + ) { It "Should set Strip[$index].Limit to 3" { $vmr.strip[$index].limit = $value $vmr.strip[$index].limit | Should -Be $expected @@ -224,7 +224,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'sr' -ForEach @( @{ Value = 44100; Expected = 44100 } @{ Value = 48000; Expected = 48000 } - ){ + ) { It "Should set vban.outstream[$index].sr to $value" { $vmr.vban.outstream[$index].sr = $value $vmr.vban.outstream[$index].sr | Should -Be $expected @@ -234,7 +234,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'channel' -ForEach @( @{ Value = 1; Expected = 1 } @{ Value = 2; Expected = 2 } - ){ + ) { It 'Should set vban.outstream[0].channel to 1' { $vmr.vban.outstream[$index].channel = $value $vmr.vban.outstream[$index].channel | Should -Be $expected @@ -246,11 +246,11 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Describe 'String Tests' { Context 'Strip, one physical, one virtual' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } - ){ + ) { It "Should set Strip[$index].Label" -ForEach @( - @{ Value = "test0"; Expected = "test0" } - @{ Value = "test1"; Expected = "test1" } - ){ + @{ Value = 'test0'; Expected = 'test0' } + @{ Value = 'test1'; Expected = 'test1' } + ) { $vmr.strip[$index].label = $value $vmr.strip[$index].label | Should -Be $expected } @@ -258,11 +258,11 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'Bus, one physical, one virtual' -ForEach @( @{ Index = $phys_out }, @{ Index = $virt_out } - ){ + ) { It "Should set Bus[$index].Label" -ForEach @( - @{ Value = "test0"; Expected = "test0" } - @{ Value = "test1"; Expected = "test1" } - ){ + @{ Value = 'test0'; Expected = 'test0' } + @{ Value = 'test1'; Expected = 'test1' } + ) { $vmr.bus[$index].label = $value $vmr.bus[$index].label | Should -Be $expected } @@ -270,11 +270,11 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Describe 'Vban' -ForEach @( @{ Index = $vban_in } - ){ + ) { Context 'instream' { 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" { $vmr.vban.instream[$index].ip = $value $vmr.vban.instream[$index].ip | Should -Be $expected @@ -284,8 +284,8 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { Context 'outstream' { 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" { $vmr.vban.outstream[$index].ip = $value $vmr.vban.outstream[$index].ip | Should -Be $expected diff --git a/tests/lower.Tests.ps1 b/tests/lower.Tests.ps1 index ad16a27..c59957b 100644 --- a/tests/lower.Tests.ps1 +++ b/tests/lower.Tests.ps1 @@ -6,13 +6,13 @@ Describe -Tag 'lower', -TestName 'All Lower Tests' { Describe 'Macrobutton Tests' -ForEach @( @{ Value = 1; Expected = 1 } @{ Value = 0; Expected = 0 } - ){ + ) { Context 'buttons 0, 69' -ForEach @( @{ Index = 0 }, @{ Index = 69 } - ){ + ) { Context 'state, stateonly and trigger' -ForEach @( @{ Mode = 1 }, @{ Mode = 2 }, @{ Mode = 3 } - ){ + ) { It "Should set and get macrobutton[$index] State" { MB_Set -ID $index -SET $value -MODE $mode MB_Get -ID $index -MODE $mode | Should -Be $expected @@ -24,13 +24,13 @@ Describe -Tag 'lower', -TestName 'All Lower Tests' { Describe 'Set and Get Param Float Tests' -ForEach @( @{ Value = 1; Expected = 1 } @{ Value = 0; Expected = 0 } - ){ + ) { Context 'Strip, one physical one virtual' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } - ){ + ) { Context 'mute, mono, A1, B2' -ForEach @( - @{ param = "mute" }, @{ param = "A1" } - ){ + @{ param = 'mute' }, @{ param = 'A1' } + ) { It "Should set Strip[0].$param to 1" { Param_Set -PARAM "Strip[$index].$param" -VALUE $value Param_Get -PARAM "Strip[$index].$param" | Should -Be $expected @@ -42,10 +42,10 @@ Describe -Tag 'lower', -TestName 'All Lower Tests' { Describe 'Set and Get Param String Tests' -ForEach @( @{ Value = 'test0'; Expected = 'test0' } @{ Value = 'test1'; Expected = 'test1' } - ){ + ) { Context 'Strip, one physical one virtual' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } - ){ + ) { It "Should set Strip[$index].Label to $value" { Param_Set -PARAM "Strip[$index].Label" -VALUE $value Param_Get -PARAM "Strip[$index].Label" -IS_STRING $true | Should -Be $expected diff --git a/tests/pre-commit.ps1 b/tests/pre-commit.ps1 deleted file mode 100644 index 8e14e7e..0000000 --- a/tests/pre-commit.ps1 +++ /dev/null @@ -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 diff --git a/tests/run.ps1 b/tests/run.ps1 new file mode 100644 index 0000000..8c4b5fd --- /dev/null +++ b/tests/run.ps1 @@ -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