Skip to content

Commit a96b3fb

Browse files
authored
add publish test results step to CI with pester test fix (#772)
* upload results from setup tests * Update test results file path in CI * Update ci.yml * Update Setup.Tests.ps1 * Add systemDrive variable and update paths * Update variable names in CI configuration * Enable task failure on failed tests * Comment out sshd service stop command to test CI * uncomment part of pester test
1 parent 8514f78 commit a96b3fb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.azdo/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ stages:
8989
pool:
9090
vmImage: windows-latest
9191
displayName: Win32-OpenSSH On Windows
92+
variables:
93+
testFilesDrivePath: '**'
9294
steps:
9395
- powershell: |
9496
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
@@ -164,6 +166,17 @@ stages:
164166
Invoke-OpenSSHTests -OpenSSHBinPath "$env:SystemDrive/OpenSSH"
165167
displayName: Run tests
166168
169+
- pwsh: |
170+
Write-Host "##vso[task.setvariable variable=testFilesDrivePath;]$env:SystemDrive"
171+
displayName: Set variable
172+
173+
- task: PublishTestResults@2
174+
inputs:
175+
testResultsFormat: 'NUnit'
176+
testResultsFiles: '$(testFilesDrivePath)/OpenSSHTests/*.xml'
177+
failTaskOnFailedTests: true
178+
condition: always()
179+
167180
- pwsh: |
168181
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
169182
#

regress/pesterTests/Setup.Tests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
1+
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
22
Import-Module $PSScriptRoot\CommonUtils.psm1 -Force
33
$suite = "Setup"
44
$tC = 1
@@ -535,6 +535,9 @@ Describe "Setup Tests" -Tags "Setup" {
535535
if (Test-Path -Path $logFolderPath) {
536536
$logACL = Get-Acl $logFolderPath
537537
}
538+
if ((Get-Service sshd).Status -eq 'Running') {
539+
net stop sshd
540+
}
538541
}
539542
AfterAll {
540543
$tC++

0 commit comments

Comments
 (0)