Skip to content

Commit

Permalink
pester
Browse files Browse the repository at this point in the history
  • Loading branch information
msftrubengu committed Aug 2, 2023
1 parent ca3edfe commit cb1c0e9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
22 changes: 15 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,27 @@ jobs:
Contents: '**\*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PowerShell@2
- pwsh: .\InstallDevCert.ps1 -pfxpath $(HTTPSDevCert.secureFilePath) -password microsoft
workingDirectory: $(Build.SourcesDirectory)\src\LocalhostWebServer
displayName: Install Root Certificate
inputs:
filePath: '$(Build.SourcesDirectory)\src\LocalhostWebServer\InstallDevCert.ps1'
arguments: '-pfxpath $(HTTPSDevCert.secureFilePath) -password microsoft'

- task: PowerShell@2
- pwsh: .\Run-LocalhostWebServer.ps1 -BuildRoot $(Pipeline.Workspace)\Build.x64release\E2ETests\LocalhostWebServer -StaticFileRoot $(Pipeline.Workspace)\Build.x64release\E2ETests\TestLocalIndex -CertPath $(HTTPSDevCert.secureFilePath) -CertPassword microsoft
workingDirectory: $(Build.SourcesDirectory)\src\LocalhostWebServer
displayName: Launch LocalhostWebServer

- pwsh: .\RunTests.ps1 -testModulesPath $(Build.ArtifactStagingDirectory) -outputPath $(Pipeline.Workspace)\PesterTest -packageLayoutPath $(Pipeline.Workspace)\Build.x64release\DevPackage
workingDirectory: $(Build.SourcesDirectory)\Tools\
displayName: Run Tests

- task: PublishTestResults@2
displayName: Publish Pester Test Results
inputs:
filePath: '$(Build.SourcesDirectory)\src\LocalhostWebServer\Run-LocalhostWebServer.ps1'
arguments: '-BuildRoot $(Pipeline.Workspace)\Build.x64release\E2ETests\LocalhostWebServer -StaticFileRoot $(Pipeline.Workspace)\Build.x64release\E2ETests\TestLocalIndex -CertPath $(HTTPSDevCert.secureFilePath) -CertPassword microsoft'
testResultsFormat: 'NUnit'
testResultsFiles: '$(Pipeline.Workspace)\PesterTest\TestsPester*.xml'
failTaskOnFailedTests: true

- task: PublishPipelineArtifact@1
displayName: Publish PowerShell Module Artifacts
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
condition: succeededOrFailed()
36 changes: 36 additions & 0 deletions src/PowerShell/tests/RunTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
[CmdletBinding()]
param(
[string]$testModulesPath,
[string]$outputPath,
[string]$packageLayoutPath,
)

# This updates pester not always necessary but worth noting
Install-Module -Name Pester -Force -SkipPublisherCheck
Import-Module Pester

$env:PSModulePath += ";$testModulesPath"

if (-not Test-Path $outputPath)
{
New-Item -Path $outputPath -ItemType Directory
}

# Register the package
if (-not [System.String]::IsNullOrEmpty($packageLayoutPath))
{
$local:packageManifestPath = Join-Path $packageLayoutPath "AppxManifest.xml"

Add-AppxPackage -Register $local:packageManifestPath

# Configure crash dump and log file settings
$local:settingsExport = ConvertFrom-Json (wingetdev.exe settings export)
$local:settingsFilePath = $local:settingsExport.userSettingsFile
$local:settingsFileContent = ConvertTo-Json @{ debugging= @{ enableSelfInitiatedMinidump=$true ; keepAllLogFiles=$true } }

Set-Content -Path $local:settingsFilePath -Value $local:settingsFileContent
}

Invoke-Pester -Script $PSScriptRoot\Microsoft.WinGet.Client.Tests.ps1 -OutputFile $outputPath\TestsPester.WinGetClient.XML -OutputFormat NUnitXML

0 comments on commit cb1c0e9

Please sign in to comment.