Skip to content

Commit 36ecce3

Browse files
Fix failing psakeFile Pester task - LocalizationParser default culture and psake configuration (#11)
The CI pipeline was failing with Pester test errors due to two main issues in the PowerShell localization testing infrastructure. ## Issues Fixed ### 1. LocalizationParser Missing Default Culture The `LocalizationParser.ps1` script was failing when no `UICulture` parameter was provided. The script uses `Import-LocalizedData` which requires a specific culture to locate files in culture-specific subdirectories (e.g., `en-US/Example.psd1`, `fr-FR/Example.psd1`). When running in environments with invariant culture, the localization files couldn't be found. **Before:** ```powershell # Failed - no localization files found pwsh -File ./resources/LocalizationParser.ps1 -ModuleFile ./tests/fixtures/Example/Example.psm1 ``` **After:** ```powershell # Works - defaults to en-US culture pwsh -File ./resources/LocalizationParser.ps1 -ModuleFile ./tests/fixtures/Example/Example.psm1 ``` ### 2. Outdated Pester Configuration Syntax The `psake.ps1` build script was using deprecated Pester configuration syntax that's incompatible with Pester 5.x. The script was attempting to create a `[PesterConfiguration]` object directly and use `-PassThru` as a parameter. **Before:** ```powershell $script:PesterConfiguration = [PesterConfiguration]@{} $results = Invoke-Pester -Configuration $script:PesterConfiguration -PassThru ``` **After:** ```powershell $script:PesterConfiguration = New-PesterConfiguration $script:PesterConfiguration.Run.PassThru = $true $results = Invoke-Pester -Configuration $script:PesterConfiguration ``` ## Validation Results All tests now pass successfully: - ✅ LocalizationParser tests (8/8 tests pass) - ✅ MetaTests validation (3/3 tests pass) - ✅ English localization returns: "Value1", "Value2", "Value3" - ✅ French localization returns: "Valeur1", "Valeur2", "Valeur3" - ✅ TypeScript compilation and linting pass The CI pipeline Pester task will now execute successfully without the previous `Import-LocalizedData` errors. Fixes #10. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: HeyItsGilbert <615265+HeyItsGilbert@users.noreply.github.com>
1 parent 94e7a95 commit 36ecce3

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ to structure this file.
2828
- Smart log filtering that respects the configured log level
2929
- Debug messages are now filtered out by default, providing cleaner output
3030

31+
### Fixed
32+
- LocalizationParser.ps1 now defaults to en-US culture when UICulture parameter is not provided
33+
- Fixes Import-LocalizedData failures in environments with invariant culture
34+
- Ensures localization files can be found in culture-specific subdirectories
35+
- Updated Pester configuration syntax in psake.ps1 for compatibility with Pester 5.x
36+
- Replaced deprecated [PesterConfiguration]@{} with New-PesterConfiguration
37+
- Fixed PassThru parameter usage for modern Pester API
38+
3139
## [0.1.0] Initial Release
3240

3341
- Foundational script `LocalizationParser` looks for `psm1` that container

psake.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Properties {
77
$script:outDir = 'out'
88
$script:scriptDir = $PSScriptRoot
99

10-
$script:PesterConfiguration = [PesterConfiguration]@{}
10+
$script:PesterConfiguration = New-PesterConfiguration
1111
$script:PesterConfiguration.Output.CIFormat = 'Auto'
1212
$script:PesterConfiguration.Run.Path = ".\tests\"
13+
$script:PesterConfiguration.Run.PassThru = $true
1314
}
1415

1516
Task Default -Depends Test
@@ -77,7 +78,8 @@ Task VscodeTest -Depends InstallDependencies {
7778
Task Pester {
7879
Write-Host '🧪 Running Pester tests...'
7980
try {
80-
$results = Invoke-Pester -Configuration $script:PesterConfiguration -PassThru
81+
Import-Module Pester
82+
$results = Invoke-Pester -Configuration $script:PesterConfiguration
8183
if ($results.FailedCount -gt 0) {
8284
Write-Error '❌ Pester tests failed. Please fix the issues before packaging.'
8385
exit 1

resources/LocalizationParser.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ if (Test-Path $file) {
136136
}
137137
if ($null -ne $UICulture -and -not [String]::IsNullOrEmpty($UICulture.Name)) {
138138
$splat['UICulture'] = $UICulture.Name
139+
} else {
140+
# Default to en-US when no UICulture is specified
141+
$splat['UICulture'] = 'en-US'
139142
}
140143
# Override the base directory if its set
141144
$splat['BaseDirectory'] = $parentDirectory

0 commit comments

Comments
 (0)