diff --git a/.azure-pipelines/PipelineSteps/test-steps.ps1 b/.azure-pipelines/PipelineSteps/test-steps.ps1 index f435bae3bd2a..86e8bb6a868a 100644 --- a/.azure-pipelines/PipelineSteps/test-steps.ps1 +++ b/.azure-pipelines/PipelineSteps/test-steps.ps1 @@ -54,6 +54,35 @@ $ErrorActionPreference = $preference Set-Location $currentPath Write-Host -ForegroundColor DarkGreen "-------------------- End testing AutoGen modules with PowerShell Core ... --------------------`n`n`n`n`n" +# Test AutoGen Modules With Windows PowerShell 5.1 +if ($IsWindows) { + Write-Host -ForegroundColor Green "-------------------- Start testing AutoGen modules with Windows PowerShell 5.1 ... --------------------" + $executeCIStepScriptPath = Join-Path $RepoRoot "tools" "ExecuteCIStep.ps1" + $currentPath = $PWD + $debugFolderPath = Join-Path $RepoRoot "artifacts" "Debug" + Set-Location $debugFolderPath + + $winPs = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' + & $winPs -NoProfile -Command @" + `$ErrorActionPreference = 'Continue' + Install-Module -Name Pester -Repository PSGallery -RequiredVersion 4.10.1 -Force + `$env:PSModulePath = `$env:PSModulePath + ';' + (pwd).Path + `$rootFolder = (Get-item `$PWD).Parent.Parent + Get-ChildItem -File -Recurse test-module.ps1 | ForEach-Object { + Write-Host `$_.Directory.FullName + cd `$rootFolder + & '$executeCIStepScriptPath' -TestAutorest -AutorestDirectory `$_.Directory.FullName + } +"@ + $winPsExitCode = $LASTEXITCODE + + Set-Location $currentPath + if ($winPsExitCode -ne 0) { + throw "Windows PowerShell 5.1 AutoGen module tests failed with exit code $winPsExitCode." + } + Write-Host -ForegroundColor DarkGreen "-------------------- End testing AutoGen modules with Windows PowerShell 5.1 ... --------------------`n`n`n`n`n" +} + # Analyze test coverage Write-Host -ForegroundColor Green "-------------------- Start analyzing test coverage ... --------------------" $validateTestCoverageScriptPath = Join-Path $RepoRoot 'tools' 'TestFx' 'Coverage' 'ValidateTestCoverage.ps1' diff --git a/.azure-pipelines/util/test-steps.yml b/.azure-pipelines/util/test-steps.yml index 17f01d1d8b2b..9b65e2c5ad47 100644 --- a/.azure-pipelines/util/test-steps.yml +++ b/.azure-pipelines/util/test-steps.yml @@ -50,6 +50,20 @@ steps: env: PowerShellPlatform: ${{ parameters.powerShellPlatform }} +- powershell: | + Install-Module -Name Pester -RequiredVersion 4.10.1 -Force + $sp = [System.IO.Path]::PathSeparator + $env:PSModulePath = $env:PSModulePath + $sp + (pwd).Path + $rootFolder = (Get-item $PWD).Parent.Parent + Get-ChildItem -File -Recurse test-module.ps1 | ForEach-Object { + Write-Host $_.Directory.FullName + cd $rootFolder + & .\tools\ExecuteCIStep.ps1 -TestAutorest -AutorestDirectory $_.Directory.FullName + } + workingDirectory: 'artifacts/Debug' + displayName: 'Test for AutoGen Modules With Windows PowerShell 5.1' + condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq('${{ parameters.testTarget }}', 'Test')) + - task: PowerShell@2 displayName: Analyze Test Coverage inputs: