azure-webjobs-sdk-extensions/run-tests.ps1

70 строки
2.0 KiB
PowerShell
Исходник Обычный вид История

2023-01-10 03:49:03 +03:00
param(
[string[]]$tests = @(),
[string]$Configuration
2023-01-10 03:49:03 +03:00
)
if (-not $Configuration) {
Write-Host "Configuration not specified, defaulting to 'Release'" -ForegroundColor Yellow
$Configuration = 'Release'
}
2023-01-10 03:49:03 +03:00
function RunTest([string]$project, [bool]$skipBuild = $false, [string]$filter = $null) {
Write-Host "Running test: $project" -ForegroundColor DarkCyan
Write-Host "-----------------------------------------------------------------------------" -ForegroundColor DarkCyan
Write-Host
$cmdargs = "test", ".\test\$project\$project.csproj", "-v", "m", "--logger", "trx;LogFileName=TEST.xml", "-c", $Configuration
2023-01-10 03:49:03 +03:00
if ($filter) {
2023-01-10 03:49:03 +03:00
Write-Host "Adding: --filter $filter"
$cmdargs += "--filter", "$filter"
}
2023-01-10 03:49:03 +03:00
Write-Host "Final command: 'dotnet $cmdargs'"
# We'll always rebuild for now.
# if ($skipBuild){
# $cmdargs += "--no-build"
# }
# else {
# Write-Host "Rebuilding project" -ForegroundColor Red
# }
& dotnet $cmdargs | Out-Host
$r = $?
Write-Host
Write-Host "-----------------------------------------------------------------------------" -ForegroundColor DarkCyan
Write-Host
return $r
}
2023-01-10 03:49:03 +03:00
if ((-not $tests) -or ($tests.Count -lt 1))
{
throw "No test projects specified to run. Exiting script."
}
$success = $true
$testRunSucceeded = $true
2018-10-08 21:25:17 +03:00
# timer tests require Daylight Savings Time, so switch settings, then reset.
$originalTZ = Get-TimeZone
Write-Host "Current TimeZone: '$originalTZ'"
Set-TimeZone -Name "Pacific Standard Time"
$currentTZ = Get-TimeZone
Write-Host "Changing TimeZone for Timer tests. Now '$currentTZ'"
Write-Host "Environment setting Configuration is '$Configuration'."
2023-01-10 03:49:03 +03:00
dotnet --version
2018-10-08 21:25:17 +03:00
foreach ($test in $tests){
2023-01-10 03:49:03 +03:00
$testRunSucceeded = RunTest $test $testRunSucceeded
$success = $testRunSucceeded -and $success
}
2018-10-08 21:25:17 +03:00
Set-TimeZone -Id $originalTZ.Id
$currentTZ = Get-TimeZone
Write-Host "Changing TimeZone back to original. Now '$currentTZ'"
if (-not $success) { exit 1 }