mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-16 00:40:46 +00:00
pre-commit.ps1 for use with git hook added
This commit is contained in:
parent
0f8615715c
commit
ad544fdcbb
31
tests/pre-commit.ps1
Normal file
31
tests/pre-commit.ps1
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
Function RunTests {
|
||||||
|
$coverage = "./tests/pytest_coverage.log"
|
||||||
|
$run_tests = "pytest -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"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user