Skip to content

Commit 3060f6d

Browse files
committed
📝 [test] Add comprehensive test coverage for ColorScripts-Enhanced module
- ✨ [feat] Introduce tests for Gap-filler 2 functionality, ensuring proper list, cache, and emission handling. - ✨ [feat] Implement targeted tests for Get-ColorScriptList, covering help, formatting, filtering, and warning scenarios. - ✨ [feat] Create tests for the installation script, validating user and all-users scope paths. - ✨ [feat] Add additional low-coverage tests for various functions, including ConvertFrom-JsonToHashtable and Get-ColorScriptAnsiSequence. - ✨ [feat] Develop tests for New-ColorScriptCache, focusing on help, validation, and sequential execution scenarios. - ✨ [feat] Implement tests for Write-ColorScriptInformation, ensuring proper handling of ANSI sequences and console output. - 👷 [ci] Update Test-Coverage script to change output format from JaCoCo to Cobertura for better compatibility. Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>
1 parent ccd812e commit 3060f6d

54 files changed

Lines changed: 2816 additions & 1081 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ColorScripts-Enhanced/ColorScripts-Enhanced.psd1

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@
88

99
@{
1010
# Script module or binary module file associated with this manifest.
11-
RootModule = 'ColorScripts-Enhanced.psm1'
11+
RootModule = 'ColorScripts-Enhanced.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '2025.11.07.1633'
14+
ModuleVersion = '2025.11.07.2324'
1515

1616
# Supported PSEditions
17-
CompatiblePSEditions = @('Desktop', 'Core')
17+
CompatiblePSEditions = @('Desktop', 'Core')
1818

1919
# ID used to uniquely identify this module
20-
GUID = 'f77548d7-23eb-48ce-a6e0-f64b4758d995'
20+
GUID = 'f77548d7-23eb-48ce-a6e0-f64b4758d995'
2121

2222
# Author of this module
23-
Author = 'Nick2bad4u'
23+
Author = 'Nick2bad4u'
2424

2525
# Company or vendor of this module
26-
CompanyName = 'Community'
26+
CompanyName = 'Community'
2727

2828
# Copyright statement for this module
29-
Copyright = '(c) 2025. All rights reserved.'
29+
Copyright = '(c) 2025. All rights reserved.'
3030

3131
# Description of the functionality provided by this module
32-
Description = @'
32+
Description = @'
3333
🎨 ColorScripts-Enhanced: Professional ANSI Art Terminal Experience
3434
3535
![ColorScripts Mascot](https://raw.githubusercontent.com/Nick2bad4u/ps-color-scripts-enhanced/main/assets/ColorScripts-Mascot-Dark.jpeg)
@@ -82,7 +82,7 @@ PERFECT FOR
8282
'@
8383

8484
# Minimum version of the PowerShell engine required by this module
85-
PowerShellVersion = '5.1'
85+
PowerShellVersion = '5.1'
8686

8787
# Name of the PowerShell host required by this module
8888
# PowerShellHostName = ''
@@ -118,7 +118,7 @@ PERFECT FOR
118118
# NestedModules = @()
119119

120120
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
121-
FunctionsToExport = @(
121+
FunctionsToExport = @(
122122
'Show-ColorScript'
123123
'Get-ColorScriptList'
124124
'New-ColorScriptCache'
@@ -132,13 +132,13 @@ PERFECT FOR
132132
)
133133

134134
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
135-
CmdletsToExport = @()
135+
CmdletsToExport = @()
136136

137137
# Variables to export from this module
138-
VariablesToExport = @()
138+
VariablesToExport = @()
139139

140140
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
141-
AliasesToExport = @('scs', 'Update-ColorScriptCache', 'Build-ColorScriptCache')
141+
AliasesToExport = @('scs', 'Update-ColorScriptCache', 'Build-ColorScriptCache')
142142

143143
# DSC resources to export from this module
144144
# DscResourcesToExport = @()
@@ -147,7 +147,7 @@ PERFECT FOR
147147
# ModuleList = @()
148148

149149
# List of all files packaged with this module
150-
FileList = @(
150+
FileList = @(
151151
'ColorScripts-Enhanced.psm1'
152152
'ColorScripts-Enhanced.psd1'
153153
'README.md'
@@ -157,10 +157,10 @@ PERFECT FOR
157157
)
158158

159159
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
160-
PrivateData = @{
160+
PrivateData = @{
161161
PSData = @{
162162
# Tags applied to this module. These help with module discovery in online galleries.
163-
Tags = @(
163+
Tags = @(
164164
'ColorScripts'
165165
'ANSI'
166166
'Terminal'
@@ -198,20 +198,20 @@ PERFECT FOR
198198
)
199199

200200
# A URL to the license for this module.
201-
LicenseUri = 'https://licenses.nuget.org/MIT'
201+
LicenseUri = 'https://licenses.nuget.org/MIT'
202202

203203
# License expression or path to license file
204-
License = 'MIT'
204+
License = 'MIT'
205205

206206
# A URL to the main website for this project.
207-
ProjectUri = 'https://github.com/Nick2bad4u/ps-color-scripts-enhanced'
207+
ProjectUri = 'https://github.com/Nick2bad4u/ps-color-scripts-enhanced'
208208

209209
# A URL to an icon representing this module.
210-
IconUri = 'https://raw.githubusercontent.com/Nick2bad4u/ps-color-scripts-enhanced/main/docs/colorscripts-icon.png'
210+
IconUri = 'https://raw.githubusercontent.com/Nick2bad4u/ps-color-scripts-enhanced/main/docs/colorscripts-icon.png'
211211

212212
# ReleaseNotes of this module
213-
ReleaseNotes = @'
214-
Version 2025.11.07.1633:
213+
ReleaseNotes = @'
214+
Version 2025.11.07.2324:
215215
- Enhanced caching system with OS-wide cache in AppData
216216
- 6-19x performance improvement
217217
- Cache stored in centralized location
@@ -236,7 +236,7 @@ Version 2025.11.07.1633:
236236
}
237237

238238
# HelpInfo URI of this module
239-
HelpInfoURI = 'https://nick2bad4u.github.io/PS-Color-Scripts-Enhanced/ColorScripts-Enhanced/'
239+
HelpInfoURI = 'https://nick2bad4u.github.io/PS-Color-Scripts-Enhanced/ColorScripts-Enhanced/'
240240

241241
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
242242
# DefaultCommandPrefix = ''

ColorScripts-Enhanced/ColorScripts-Enhanced.psm1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function Write-ModuleTrace {
143143
}
144144
}
145145

146-
Write-ModuleTrace ("--- Import begin: {0} ---" -f (Get-Date -Format o))
146+
Write-ModuleTrace ('--- Import begin: {0} ---' -f (Get-Date -Format o))
147147

148148
$moduleInfo = $ExecutionContext.SessionState.Module
149149
$moduleRootCandidates = @()
@@ -172,7 +172,7 @@ if ($environmentRoot) {
172172
$moduleRootCandidates += $environmentRoot
173173
}
174174

175-
Write-ModuleTrace ("Initial module root candidates: {0}" -f ($moduleRootCandidates -join ';'))
175+
Write-ModuleTrace ('Initial module root candidates: {0}' -f ($moduleRootCandidates -join ';'))
176176

177177
$resolvedCandidates = @()
178178
foreach ($candidate in $moduleRootCandidates) {
@@ -189,7 +189,7 @@ foreach ($candidate in $moduleRootCandidates) {
189189
}
190190

191191
$moduleRootCandidates = $resolvedCandidates
192-
Write-ModuleTrace ("Resolved module root candidates: {0}" -f ($moduleRootCandidates -join ';'))
192+
Write-ModuleTrace ('Resolved module root candidates: {0}' -f ($moduleRootCandidates -join ';'))
193193

194194
$cultureFallback = @()
195195
try {
@@ -318,7 +318,7 @@ if (-not $script:DelegateSyncRoot) { $script:DelegateSyncRoot = New-Object Syste
318318
$privateDirectory = Join-Path -Path $PSScriptRoot -ChildPath 'Private'
319319
if (Test-Path -LiteralPath $privateDirectory) {
320320
Get-ChildItem -Path $privateDirectory -Filter '*.ps1' -File | Sort-Object Name | ForEach-Object {
321-
Write-ModuleTrace ("Loading private script: {0}" -f $_.Name)
321+
Write-ModuleTrace ('Loading private script: {0}' -f $_.Name)
322322
. $_.FullName
323323
}
324324
}
@@ -347,12 +347,12 @@ if ($script:ModuleRoot) {
347347
}
348348
}
349349
catch {
350-
Write-ModuleTrace ("Resolve-Path for module root failed: {0}" -f $_.Exception.Message)
350+
Write-ModuleTrace ('Resolve-Path for module root failed: {0}' -f $_.Exception.Message)
351351
}
352352

353353
$script:ScriptsPath = Join-Path -Path $script:ModuleRoot -ChildPath 'Scripts'
354354
$script:MetadataPath = Join-Path -Path $script:ModuleRoot -ChildPath 'ScriptMetadata.psd1'
355-
Write-ModuleTrace ("Module root finalized at {0}" -f $script:ModuleRoot)
355+
Write-ModuleTrace ('Module root finalized at {0}' -f $script:ModuleRoot)
356356
}
357357
else {
358358
Write-ModuleTrace 'Module root could not be determined; relative operations may fail.'
@@ -361,7 +361,7 @@ else {
361361
$publicDirectory = Join-Path -Path $PSScriptRoot -ChildPath 'Public'
362362
if (Test-Path -LiteralPath $publicDirectory) {
363363
Get-ChildItem -Path $publicDirectory -Filter '*.ps1' -File | Sort-Object Name | ForEach-Object {
364-
Write-ModuleTrace ("Loading public script: {0}" -f $_.Name)
364+
Write-ModuleTrace ('Loading public script: {0}' -f $_.Name)
365365
. $_.FullName
366366
}
367367
}
@@ -395,8 +395,8 @@ try {
395395
Invoke-ColorScriptsStartup
396396
}
397397
catch {
398-
Write-ModuleTrace ("Startup invocation failure: {0}" -f $_.Exception.Message)
399-
Write-Verbose ("Auto-show on import skipped: {0}" -f $_.Exception.Message)
398+
Write-ModuleTrace ('Startup invocation failure: {0}' -f $_.Exception.Message)
399+
Write-Verbose ('Auto-show on import skipped: {0}' -f $_.Exception.Message)
400400
}
401401

402-
Write-ModuleTrace ("--- Import complete: {0} ---" -f (Get-Date -Format o))
402+
Write-ModuleTrace ('--- Import complete: {0} ---' -f (Get-Date -Format o))

ColorScripts-Enhanced/Private/Test-ConsoleSupportsVirtualTerminal.ps1

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,52 @@ function Test-ConsoleSupportsVirtualTerminal {
4343
return $false
4444
}
4545

46+
$overrides = $null
47+
$useOverrides = $false
48+
if ($script:ConsoleNativeOverrides -and ($script:ConsoleNativeOverrides.Enabled -eq $true)) {
49+
$overrides = $script:ConsoleNativeOverrides
50+
$useOverrides = $true
51+
}
52+
53+
$getStdHandle = if ($useOverrides -and $overrides.GetStdHandle) {
54+
$overrides.GetStdHandle
55+
}
56+
else {
57+
{ param([int]$handleId) [ColorScriptsEnhanced.ConsoleNative]::GetStdHandle($handleId) }
58+
}
59+
60+
$getConsoleMode = if ($useOverrides -and $overrides.GetConsoleMode) {
61+
$overrides.GetConsoleMode
62+
}
63+
else {
64+
{ param([IntPtr]$handle, [ref]$mode) [ColorScriptsEnhanced.ConsoleNative]::GetConsoleMode($handle, [ref]$mode) }
65+
}
66+
67+
$setConsoleMode = if ($useOverrides -and $overrides.SetConsoleMode) {
68+
$overrides.SetConsoleMode
69+
}
70+
else {
71+
{ param([IntPtr]$handle, [int]$mode) [ColorScriptsEnhanced.ConsoleNative]::SetConsoleMode($handle, $mode) }
72+
}
73+
4674
try {
47-
$handle = [ColorScriptsEnhanced.ConsoleNative]::GetStdHandle($STD_OUTPUT_HANDLE)
75+
$handle = & $getStdHandle $STD_OUTPUT_HANDLE
4876
if ($handle -eq [IntPtr]::Zero) {
4977
return $false
5078
}
5179

5280
$mode = 0
53-
if (-not [ColorScriptsEnhanced.ConsoleNative]::GetConsoleMode($handle, [ref]$mode)) {
81+
if (-not (& $getConsoleMode $handle ([ref]$mode))) {
5482
return $false
5583
}
5684

5785
if (($mode -band $ENABLE_VIRTUAL_TERMINAL_PROCESSING) -ne 0) {
5886
return $true
5987
}
6088

61-
if ([ColorScriptsEnhanced.ConsoleNative]::SetConsoleMode($handle, $mode -bor $ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
89+
if (& $setConsoleMode $handle ($mode -bor $ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
6290
$updatedMode = 0
63-
if ([ColorScriptsEnhanced.ConsoleNative]::GetConsoleMode($handle, [ref]$updatedMode)) {
91+
if (& $getConsoleMode $handle ([ref]$updatedMode)) {
6492
return (($updatedMode -band $ENABLE_VIRTUAL_TERMINAL_PROCESSING) -ne 0)
6593
}
6694
}

ColorScripts-Enhanced/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ The `-Parallel` switch enables a runspace pool, while `-Threads` (alias for `-Th
374374

375375
Auto mode prefers PSD1 resources whenever they exist so you can override English strings without recompiling the module. Fine-tune the behaviour with `COLOR_SCRIPTS_ENHANCED_LOCALIZATION_MODE`:
376376

377-
- `auto` *(default)* – load PSD1 files when present, otherwise fall back to embedded messages.
377+
- `auto` _(default)_ – load PSD1 files when present, otherwise fall back to embedded messages.
378378
- `full` – always load from disk, even if embedded defaults would succeed.
379379
- `embedded` – skip PSD1 probes and rely on built-in English messages.
380380

ColorScripts-Enhanced/Test-AllColorScripts.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ param(
5151
[switch]$SkipErrors,
5252

5353
[Parameter()]
54-
[string]$Filter = "*",
54+
[string]$Filter = '*',
5555

5656
[Parameter()]
5757
[switch]$Parallel,
@@ -141,8 +141,8 @@ function Invoke-ColorScriptRun {
141141
$runnerDefinition = "function Invoke-ColorScriptRun {`n$((Get-Command Invoke-ColorScriptRun -CommandType Function).Definition)`n}"
142142

143143
Write-Host "`n+====================================================================+" -ForegroundColor Cyan
144-
Write-Host "| ColorScripts Enhanced - Test All Scripts |" -ForegroundColor Cyan
145-
Write-Host "+====================================================================+" -ForegroundColor Cyan
144+
Write-Host '| ColorScripts Enhanced - Test All Scripts |' -ForegroundColor Cyan
145+
Write-Host '+====================================================================+' -ForegroundColor Cyan
146146
Write-Host "`nFound $recordCount colorscript(s) to test`n" -ForegroundColor Yellow
147147

148148
$successful = 0
@@ -153,7 +153,7 @@ $initialEap = $ErrorActionPreference
153153

154154
if ($Parallel) {
155155
if ($PSVersionTable.PSVersion.Major -lt 7) {
156-
throw "-Parallel requires PowerShell 7 or later."
156+
throw '-Parallel requires PowerShell 7 or later.'
157157
}
158158

159159
$parallelResults = $records | ForEach-Object -Parallel {
@@ -190,7 +190,7 @@ else {
190190
Write-Host $record.Name -ForegroundColor White
191191
}
192192
Write-Host ('-' * 70) -ForegroundColor DarkGray
193-
Write-Host ""
193+
Write-Host ''
194194

195195
try {
196196
$ErrorActionPreference = 'Stop'
@@ -240,13 +240,13 @@ $ErrorActionPreference = $initialEap
240240

241241
Write-Host "`n"
242242
Write-Host ('=' * 70) -ForegroundColor Cyan
243-
Write-Host " TEST SUMMARY " -ForegroundColor Cyan
243+
Write-Host ' TEST SUMMARY ' -ForegroundColor Cyan
244244
Write-Host ('=' * 70) -ForegroundColor Cyan
245245
Write-Host "`nTotal Scripts: " -NoNewline
246246
Write-Host $recordCount -ForegroundColor White
247-
Write-Host "Successful: " -NoNewline
247+
Write-Host 'Successful: ' -NoNewline
248248
Write-Host $successful -ForegroundColor Green
249-
Write-Host "Failed: " -NoNewline
249+
Write-Host 'Failed: ' -NoNewline
250250
Write-Host $failed -ForegroundColor $(if ($failed -gt 0) { 'Red' } else { 'Green' })
251251

252252
if ($failedScripts.Count -gt 0) {

ColorScripts-Enhanced/de/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>de</UICultureName>
7-
<UICultureVersion>2025.11.07.1633</UICultureVersion>
7+
<UICultureVersion>2025.11.08.0008</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

ColorScripts-Enhanced/en-US/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>en-US</UICultureName>
7-
<UICultureVersion>2025.11.07.1633</UICultureVersion>
7+
<UICultureVersion>2025.11.08.0008</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

ColorScripts-Enhanced/es/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>es</UICultureName>
7-
<UICultureVersion>2025.11.07.1633</UICultureVersion>
7+
<UICultureVersion>2025.11.08.0008</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

ColorScripts-Enhanced/fr/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>fr</UICultureName>
7-
<UICultureVersion>2025.11.07.1633</UICultureVersion>
7+
<UICultureVersion>2025.11.08.0008</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

ColorScripts-Enhanced/it/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>it</UICultureName>
7-
<UICultureVersion>2025.11.07.1633</UICultureVersion>
7+
<UICultureVersion>2025.11.08.0008</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

0 commit comments

Comments
 (0)