Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try on pwsh #61

Merged
merged 22 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions .github/workflows/pester.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
name: Pester
on: [push, pull_request, workflow_dispatch]
jobs:
# test-pwsh:
# strategy:
# matrix:
# platform: [ubuntu-latest, macos-latest, windows-latest]
# runs-on: ${{ matrix.platform }}
# steps:
# - uses: actions/checkout@v4
# - name: Run Pester tests (pwsh)
# run: |
# Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor
# Install-Module -Name Pester -RequiredVersion 5.2.2 -Confirm:$false -Force
# Set-Location -Path .\Tests\
# Invoke-Pester
# if ($Error[0].Fullyqualifiederrorid -eq 'PesterAssertionFailed') {exit 1}
# shell: pwsh
test-pwsh:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Run Pester tests (pwsh)
run: |
dir env:
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor
Install-Module -Name Pester -RequiredVersion 5.6.1 -Confirm:$false -Force
Set-Location -Path .\Tests\
Invoke-Pester
if ($Error[0].Fullyqualifiederrorid -eq 'PesterAssertionFailed') {exit 1}
shell: pwsh

test-posh:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Run Pester tests (PowerShell)
run: |
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor
Install-Module -Name Pester -RequiredVersion 5.6.1 -Confirm:$false -Force
$pesterConfig = New-PesterConfiguration
$pesterConfig.CodeCoverage.Enabled = $true
Set-Location -Path .\Tests\
Invoke-Pester -Configuration $pesterConfig
if ($Error[0].Fullyqualifiederrorid -eq 'PesterAssertionFailed') {exit 1}
shell: powershell
test-posh:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Run Pester tests (PowerShell)
run: |
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor
Install-Module -Name Pester -RequiredVersion 5.6.1 -Confirm:$false -Force
$pesterConfig = New-PesterConfiguration
$pesterConfig.CodeCoverage.Enabled = $true
Set-Location -Path .\Tests\
Invoke-Pester -Configuration $pesterConfig
if ($Error[0].Fullyqualifiederrorid -eq 'PesterAssertionFailed') {exit 1}
shell: powershell
2 changes: 1 addition & 1 deletion Tests/Commands.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
BeforeAll {
$Script:PSDK_FORCE_OFFLINE = $true
Mock-PSDK-Dir
Remove-Item $Global:PSDK_DIR -Recurse
Remove-Item $Global:PSDK_DIR -Recurse -Force
Dismissed Show dismissed Hide dismissed
Mock Initialize-Posh-SDK -verifiable
Mock Initialize-Candidate-Cache -verifiable
Mock Show-Help
Expand Down
9 changes: 6 additions & 3 deletions Tests/TestUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

function Mock-PSDK-Dir {
$Script:backup_PSDK_DIR = $Global:PSDK_DIR
New-Item -ItemType Directory "TestDrive:.posh-sdk" | Out-Null
$Global:PSDK_DIR = (Get-Item "TestDrive:.posh-sdk").FullName
$randomName = (-join ((65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_}))
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

Check warning

Code scanning / PSScriptAnalyzer

'%' is an alias of 'ForEach-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content. Warning

'%' is an alias of 'ForEach-Object'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.
$tempDir = [System.IO.Path]::GetTempPath()
$testPath = "$tempDir\$randomName"
New-Item -ItemType Directory "$testPath\.posh-sdk"
$Global:PSDK_DIR = (Get-Item "$testPath\.posh-sdk" -Force).FullName
Dismissed Show dismissed Hide dismissed
New-Item -ItemType Directory "$Global:PSDK_DIR\grails" | Out-Null
}

Expand Down Expand Up @@ -54,4 +57,4 @@

function Reset-Dispatcher-Test {
Reset-PSDK-Dir
}
}
Loading