From 2f1508e8f14882de6a48e0f9cb28acdebd525bdc Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sat, 1 May 2021 22:20:21 +0100 Subject: [PATCH] update readme, runall and gitignore Update installation instructions in README. Added logging and log parsing to runall.ps1 Add ignore log files --- .gitignore | 1 + CHANGELOG.md | 2 ++ FROM_SOURCE.md | 2 +- README.md | 24 ++++++++++++++++++------ test/higher.Tests.ps1 | 12 ++++++------ test/runall.ps1 | 39 +++++++++++++++++++++++++++++++++++++-- 6 files changed, 65 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 79ba68b..bbbc3e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ **/*.psd1 +**/*.log diff --git a/CHANGELOG.md b/CHANGELOG.md index c76c419..ffe60a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Before any minor/major patch is released all test units will be run to verify th ## [Unreleased] - [x] Add gain, comp, limit to Strips - [x] Update tests to reflect changes +- [x] Add logging + summary for tests +- [x] Add info to README about powershellget, nuget and psgallery ## [1.3] - 2021-04-30 ### Added diff --git a/FROM_SOURCE.md b/FROM_SOURCE.md index ff7d442..f6e410c 100644 --- a/FROM_SOURCE.md +++ b/FROM_SOURCE.md @@ -12,7 +12,7 @@ Simple example if using from source: Import-Module .\lib\Voicemeeter.psm1 try { - # Pass a Voicemeeter type as argument + # Run the factory function for required Voicemeeter type $vmr = Get-RemoteBanana # Set strip and bus params diff --git a/README.md b/README.md index 31c020b..c6ce562 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,23 @@ You may have success with many commands in earlier versions but some commands - Powershell 5.1 ## Installation -#### Powershell: +#### PowerShellGet: +In Powershell as admin: + `Install-Module Voicemeeter` -You will need to add PSGallery as a trusted repository source. -More info: [PSGallery](https://www.powershellgallery.com/) +In Powershell as current user: + +`Install-Module -Name Voicemeeter -Scope CurrentUser` + +You may be asked to install NuGet provider required by PowerShellGet if you don't have it already. + +When prompted you will need to accept PSGallery as a trusted repository. + +More Info: +- [PowerShellGet](https://docs.microsoft.com/en-us/powershell/scripting/gallery/installing-psget?view=powershell-7.1) +- [NuGet](https://www.powershellgallery.com/packages/NuGet/1.3.3) +- [PSGallery](https://docs.microsoft.com/en-gb/powershell/scripting/gallery/overview?view=powershell-7.1) #### Direct download: `git clone https://github.com/onyx-and-iris/voicemeeter-api-powershell.git` @@ -99,9 +111,7 @@ $vmr.button[5].trigger = $true ``` ### Run tests -Run tests using invoke-pester in powershell console from test directory. - -Alternatively you may use .\runall.ps1 which accepts two parameters: +Run tests using .\runall.ps1 which accepts two parameters: - tag Run tests of this type - num Run this number of tests @@ -109,3 +119,5 @@ Current test types are 'higher' and 'lower' Example: `.\runall.ps1 -tag 'higher' -num 3` + +Results will be logged and summary file written. diff --git a/test/higher.Tests.ps1 b/test/higher.Tests.ps1 index afbbf62..ae7551a 100644 --- a/test/higher.Tests.ps1 +++ b/test/higher.Tests.ps1 @@ -402,9 +402,9 @@ Describe -Tag 'higher', -TestName 'All Alias Tests' { $vmr.strip[1].gain | Should -Be 5.1 } - It 'Should set Strip[1].Gain to -0.2' { - $vmr.strip[1].gain =-0.2 - $vmr.strip[1].gain | Should -Be -0.2 + It 'Should set Strip[1].Gain to -4.2' { + $vmr.strip[1].gain = -4.2 + $vmr.strip[1].gain | Should -Be -4.2 } It 'Should set Strip[2].Gain to 2.7' { @@ -594,9 +594,9 @@ Describe -Tag 'higher', -TestName 'All Alias Tests' { $vmr.bus[1].gain | Should -Be 5.1 } - It 'Should set Bus[1].Gain to -0.2' { - $vmr.bus[1].gain =-0.2 - $vmr.bus[1].gain | Should -Be -0.2 + It 'Should set Bus[1].Gain to -4.2' { + $vmr.bus[1].gain = -4.2 + $vmr.bus[1].gain | Should -Be -4.2 } It 'Should set Bus[2].Gain to 2.7' { diff --git a/test/runall.ps1 b/test/runall.ps1 index 555092a..c1076b0 100644 --- a/test/runall.ps1 +++ b/test/runall.ps1 @@ -2,14 +2,49 @@ Param([String]$tag, [Int]$num=1) Import-Module ..\lib\Voicemeeter.psm1 . ..\lib\base.ps1 +Function ParseLog { + Param([String]$logfile) + $summary_file = "_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 +} + + try { $vmr = Get-RemotePotato + $logfile = "_results.log" + if (Test-Path $logfile) { Clear-Content $logfile } + 1..$num | ForEach-Object { - Write-Host "Running test $_ of $num" - Invoke-Pester -Tag $tag + "Running test $_ of $num" | Tee-Object -FilePath $logfile -Append + Invoke-Pester -Tag $tag -PassThru | Tee-Object -FilePath $logfile -Append } + + Parselog -logfile $logfile } finally {