2022-04-28 11:34:48 +01:00
|
|
|
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"
|
|
|
|
|
2022-04-29 23:06:40 +01:00
|
|
|
Clear-Content $coverage
|
2022-04-28 11:34:48 +01:00
|
|
|
|
|
|
|
ForEach ($line in $(Invoke-Expression $run_tests)) {
|
|
|
|
If ( $line -Match $match_pattern ) {
|
|
|
|
if ( $line -Match "^Running tests for kind \[(\w+)\]" ) { $kind = $Matches[1] }
|
2022-04-29 23:06:40 +01:00
|
|
|
$line | Tee-Object -FilePath $coverage -Append
|
2022-04-28 11:34:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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 {
|
2022-04-29 23:06:40 +01:00
|
|
|
|
2022-04-28 11:34:48 +01:00
|
|
|
return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
|
2022-04-29 23:06:40 +01:00
|
|
|
|
2022-04-28 11:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($MyInvocation.InvocationName -ne ".") {
|
|
|
|
Invoke-Expression ".\venv\Scripts\Activate.ps1"
|
|
|
|
|
|
|
|
RunTests
|
|
|
|
|
|
|
|
Invoke-Expression "deactivate"
|
|
|
|
}
|