voicemeeter-api-python/tests/pre-commit.ps1
onyx-and-iris 312d5847ef fx, xy unit tests added to higher.
add --run-slow flag for pytest in conftest.py

run --run-slow in pre-commit

call tests.command.reset() before each test run
2022-07-16 21:22:45 +01:00

32 lines
957 B
PowerShell

Function RunTests {
$coverage = "./tests/pytest_coverage.log"
$run_tests = "pytest --run-slow -v --capture=tee-sys --junitxml=./tests/.coverage.xml"
$match_pattern = "^=|^\s*$|^Running|^Using|^plugins|^collecting|^tests"
if ( Test-Path $coverage ) { Clear-Content $coverage }
ForEach ($line in $(Invoke-Expression $run_tests)) {
If ( $line -Match $match_pattern ) {
if ( $line -Match "^Running tests for kind \[(\w+)\]" ) { $kind = $Matches[1] }
$line | Tee-Object -FilePath $coverage -Append
}
}
Write-Output "$(Get-TimeStamp)" | Out-File $coverage -Append
Invoke-Expression "genbadge tests -t 90 -i ./tests/.coverage.xml -o ./tests/$kind.svg"
}
Function Get-TimeStamp {
return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
}
if ($MyInvocation.InvocationName -ne ".") {
Invoke-Expression ".\.venv\Scripts\Activate.ps1"
RunTests
Invoke-Expression "deactivate"
}