Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ecb272d
Update WinToolkit-template.ps1
Magnetarman May 9, 2026
8ab438a
Create Install-Office.ps1
Magnetarman May 9, 2026
01e998e
Create Repair-Office.ps1
Magnetarman May 9, 2026
eb46989
Create Uninstall-Office.ps1
Magnetarman May 9, 2026
f90353a
Update CI_UpdateWinToolkit_Dev.yml
Magnetarman May 9, 2026
a01611c
Delete OfficeToolkit.ps1
Magnetarman May 9, 2026
969ae67
Update WinToolkit-template.ps1
Magnetarman May 9, 2026
6443c02
Update Uninstall-Office.ps1
Magnetarman May 9, 2026
ae0647a
Update CI_UpdateWinToolkit_Dev.yml
Magnetarman May 9, 2026
2dcf4a8
Update CI_UpdateWinToolkit_Dev.yml
Magnetarman May 9, 2026
5e79e58
Update CI_UpdateWinToolkit_Dev.yml
Magnetarman May 9, 2026
c352549
Update WinToolkit.ps1
Magnetarman May 9, 2026
029c6e7
Update Uninstall-Office.ps1
Magnetarman May 9, 2026
91fe926
Update WinToolkit-template.ps1
Magnetarman May 9, 2026
6eac897
Update WinToolkit.Tests.ps1
Magnetarman May 9, 2026
e88a0bb
Update WinToolkit-template.ps1
Magnetarman May 9, 2026
103c07b
Update Test-CompiledScript.ps1
Magnetarman May 9, 2026
289a4c1
Update WinToolkit-template.ps1
Magnetarman May 9, 2026
dc6a610
Update Test-CompiledScript.ps1
Magnetarman May 9, 2026
6ed0c23
Update WinToolkit-template.ps1
Magnetarman May 9, 2026
ab4259d
Update Test-CompiledScript.ps1
Magnetarman May 9, 2026
09425a8
Update CI_UpdateWinToolkit_Dev.yml
Magnetarman May 9, 2026
0f49af7
Create Create_Release.yml
Magnetarman May 9, 2026
a5e9aea
Update Release_Wintoolkit.yml
Magnetarman May 9, 2026
d45fee9
Sync To Dev
Magnetarman May 9, 2026
d6c3051
Update
Magnetarman May 9, 2026
8f89201
Merge branch 'Dev' into ENHANCEMENT-Pipeline-CI/CD-V-3.1.0
Magnetarman May 9, 2026
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
56 changes: 44 additions & 12 deletions .github/scripts/Test-CompiledScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

.NOTES
Autore: MagnetarMan
Version: 1.0.4
Version: 1.0.6
#>

[CmdletBinding()]
Expand All @@ -20,7 +20,10 @@ param(
[string]$ScriptPath = "WinToolkit.ps1",

[Parameter(Mandatory = $false)]
[string]$ToolPath = "tool"
[string]$ToolPath = "tool",

[Parameter(Mandatory = $false)]
[string]$TemplatePath = "WinToolkit-template.ps1"
)

# --- Best Practices PowerShell ---
Expand Down Expand Up @@ -112,6 +115,7 @@ try {
$presentFunctions = @()
$missingFunctions = @()
$emptyFunctions = @()
$devFunctions = @()

foreach ($funcName in $expectedFunctions) {
$funcAst = $functions | Where-Object { $_.Name -eq $funcName }
Expand All @@ -127,20 +131,51 @@ try {
}
}
else {
$missingFunctions += $funcName
# Se manca nel compilato, controlliamo nel template (perché la minificazione rimuove i commenti)
$templateContent = if (Test-Path $TemplatePath) { Get-Content -Raw $TemplatePath } else { "" }

if ($templateContent -match "(?m)^\s*#\s*(function\s+)?$funcName\s*\{") {
$devFunctions += $funcName
}
elseif ($templateContent -match "(?m)^\s*function\s+$funcName\s*\{") {
# Presente nel template ma non nel compilato? Strano, ma lo consideriamo in sviluppo/saltato
$devFunctions += $funcName
}
else {
$missingFunctions += $funcName
}
}
}

Write-TestLog -Message " 📊 Funzioni attese: $($expectedFunctions.Count)" -Type Info
Write-TestLog -Message " 📊 Funzioni presenti: $($presentFunctions.Count)" -Type Success
Write-TestLog -Message " 📊 Funzioni vuote: $($emptyFunctions.Count)" -Type Warning
Write-TestLog -Message " 📊 Funzioni mancanti: $($missingFunctions.Count)" -Type Warning

if ($devFunctions.Count -gt 0) {
Write-TestLog -Message " 🚧 Funzioni in sviluppo (commentate): $($devFunctions.Count)" -Type Info
foreach ($f in $devFunctions) { Write-TestLog -Message " → $f (In Sviluppo)" -Type Info }
}

if ($emptyFunctions.Count -gt 0) {
Write-TestLog -Message " ⚠️ Funzioni vuote: $($emptyFunctions.Count)" -Type Warning
foreach ($f in $emptyFunctions) { Write-TestLog -Message " → $f (Vuota)" -Type Warning }
}

if ($presentFunctions.Count -eq $expectedFunctions.Count) {
$script:TestResults += "✅ Funzioni: Tutte presenti e compilate ($($presentFunctions.Count))"
if ($missingFunctions.Count -gt 0) {
Write-TestLog -Message " ❌ Funzioni MANCANTI: $($missingFunctions.Count)" -Type Error
foreach ($f in $missingFunctions) { Write-TestLog -Message " → $f (NON TROVATA)" -Type Error }
}

if ($missingFunctions.Count -eq 0) {
$status = "✅ Funzioni: Tutte gestite ($($presentFunctions.Count) attive"
if ($devFunctions.Count -gt 0) { $status += ", $($devFunctions.Count) in sviluppo" }
$status += ")"
$script:TestResults += $status
}
else {
$script:TestResults += "ℹ️ Funzioni: $($presentFunctions.Count)/$($expectedFunctions.Count) presenti"
$script:TestResults += "❌ Funzioni: $($presentFunctions.Count)/$($expectedFunctions.Count) presenti"
$script:TotalErrors++
$errorMsg = "MODULI MANCANTI NEL TEMPLATE: I seguenti script in /tool non hanno un placeholder (nemmeno commentato) in WinToolkit-template.ps1: $($missingFunctions -join ', ')"
$script:CriticalErrors += $errorMsg
}

$script:TotalWarnings += $emptyFunctions.Count
Expand All @@ -151,10 +186,7 @@ try {
Write-TestLog -Message "`n🔍 Test 3: Verifica struttura menu..." -Type Info

$menuTests = @(
@{ Pattern = [regex]::Escape("while (`$true)"); Name = "Menu principale" },
@{ Pattern = "Windows & Office"; Name = "Categoria Windows & Office" },
@{ Pattern = "Driver & Gaming"; Name = "Categoria Driver & Gaming" },
@{ Pattern = "Supporto"; Name = "Categoria Supporto" }
@{ Pattern = [regex]::Escape("while (`$true)"); Name = "Menu principale" }
)

foreach ($test in $menuTests) {
Expand Down
17 changes: 10 additions & 7 deletions .github/tests/WinToolkit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ BeforeAll {
$Global:CurrentToolName = 'PesterTest'
$Global:GuiSessionActive = $false

# Mock globale di Read-Host per evitare hang in CI
Mock Read-Host { return '' }
# Mock globale per evitare hang in CI se una funzione chiama Read-Host inaspettatamente
Mock Read-Host { throw "Input richiesto in ambiente CI (Headless)! Assicurati di passare RawInput o mockare la chiamata." }
}

# =============================================================================
Expand Down Expand Up @@ -278,12 +278,12 @@ Describe 'Write-ToolkitLog' {

Context 'Protezione Mutex — scritture concorrenti' {

It 'Deve preservare tutte le entry sotto scrittura concorrente (5 runspace x 10 entry = 50)' {
It 'Deve preservare tutte le entry sotto scrittura concorrente (5 runspace x 5 entry = 25)' {
$tmpLog = [System.IO.Path]::GetTempFileName()

# Estraiamo le definizioni delle funzioni necessarie per evitare di ricaricare tutto il template
$writeToolkitLogDef = Get-Command Write-ToolkitLog | Select-Object -ExpandProperty Definition
$writeHostMockDef = "function Write-Host { param([Object]`$Object, [switch]`$NoNewline, [string]`$ForegroundColor) }" # Mock minimalista
# Ogni runspace dot-sourca il template e scrive 5 entry
# Ridotto a 5 runspace per non sovraccaricare il runner CI
$templatePathStr = $script:TemplatePath.Path

$jobs = 1..5 | ForEach-Object {
$idx = $_
Expand All @@ -306,7 +306,10 @@ Describe 'Write-ToolkitLog' {
}

$lines = Get-Content -Path $tmpLog | Where-Object { $_ -match 'THREAD-\d+-ENTRY-\d+' }
$lines.Count | Should -Be 50

# Senza mutex potrebbero esserci entry mancanti o corrotte
$lines.Count | Should -Be 25

Remove-Item $tmpLog -ErrorAction SilentlyContinue
}
}
Expand Down
Loading
Loading