Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ App windows use the PrintMaster logo and attribution. The scan-folder desktop sh

Click the gear icon to enable/disable individual steps.

Choosing **Cancel** or closing the initial setup window exits normally without running the selected setup steps or displaying a loader error.

![Settings](img/scans-settings.png)

Wait for the utility to complete all changes.
Expand Down
2 changes: 1 addition & 1 deletion src/scans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ if ($setupResult -eq $true) {
}
else {
Write-Verbose "User canceled scanning setup"
Exit 1
Exit 0
}
$details = New-Object System.Collections.ArrayList
$script:progressMax = 2
Expand Down
24 changes: 24 additions & 0 deletions tests/Scans.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ Describe 'Scan account password errors' {
}
}

Describe 'Setup cancellation' {
It 'exits successfully without continuing setup when Cancel or window close dismisses the dialog' {
$decision = $ast.Find({
param($node)
$node -is [System.Management.Automation.Language.IfStatementAst] -and
$node.Clauses[0].Item1.Extent.Text -eq '$setupResult -eq $true'
}, $true)
$decision | Should Not BeNullOrEmpty
foreach ($result in @('$false', '$null')) {
$childScript = @(
'$ErrorActionPreference = "Stop"'
"`$setupResult = $result"
$decision.Extent.Text
'throw "Canceled setup must not continue."'
) -join "`n"
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($childScript))
$executable = (Get-Process -Id $PID).Path
$output = & $executable -NoProfile -NonInteractive -STA -EncodedCommand $encoded 2>&1
$LASTEXITCODE | Should Be 0
($output | Out-String).Trim() | Should BeNullOrEmpty
}
}
}

Describe 'Account-dependent setup steps' {
BeforeEach {
$source = Get-Content $sourcePath -Raw
Expand Down
Loading