Skip to content
Open
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
26 changes: 26 additions & 0 deletions scripts/smoke-default-xcl.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Run with powershell.exe or pwsh.exe. smoke.ps1 started with `-File` and no -Xcl looks for
# target\release\xcl.exe next to its own folder. Windows PowerShell 5.1 leaves $PSScriptRoot empty in
# the parameter defaults of a script with [Parameter()] attributes when it is started with -File, so a
# default there made Join-Path fail before the script could say anything.
$ErrorActionPreference = 'Stop'
$fixture = Join-Path ([IO.Path]::GetTempPath()) ('xcl-smoke-default-' + [guid]::NewGuid())
$scripts = Join-Path $fixture 'scripts'
$null = New-Item -ItemType Directory -Path $scripts
try {
# a copy outside the repository: no xcl.exe is there, so the script stops before it runs anything
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'smoke.ps1') -Destination $scripts
$shell = (Get-Process -Id $PID).Path
$ErrorActionPreference = 'Continue'
$output = & $shell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File (Join-Path $scripts 'smoke.ps1') -Game $fixture 2>&1 | Out-String
$ErrorActionPreference = 'Stop'
# the child's error text can be wrapped at its console width; PowerShell 7 also colours it (ANSI
# escapes) and starts each wrapped line with `|`
$flat = $output -replace '\x1b\[[0-?]*[ -/]*[@-~]', '' -replace '[\s|]', ''
$expected = ('no ' + (Join-Path $scripts '..\target\release\xcl.exe') + ' - build it first') -replace '[\s|]', ''
if (!$flat.Contains($expected)) {
throw "smoke.ps1 without -Xcl did not look for xcl.exe next to its folder; its output:`n$output"
}
} finally {
$ErrorActionPreference = 'Stop'
if (Test-Path -LiteralPath $fixture) { Remove-Item -LiteralPath $fixture -Recurse -Force }
}
5 changes: 4 additions & 1 deletion scripts/smoke.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
param(
[Parameter(Mandatory = $true)][string]$Game,
[int]$Seconds = 60,
[string]$Xcl = (Join-Path $PSScriptRoot '..\target\release\xcl.exe')
[string]$Xcl
)
$ErrorActionPreference = 'Stop'
# Windows PowerShell 5.1 leaves $PSScriptRoot empty in this script's parameter defaults when it is
# started with -File, so the default is set here
if (-not $Xcl) { $Xcl = Join-Path $PSScriptRoot '..\target\release\xcl.exe' }

if (-not (Test-Path $Xcl)) { throw "no $Xcl - build it first (cargo build --release -p xcl)" }
$root = Split-Path $PSScriptRoot -Parent
Expand Down
Loading