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
5 changes: 5 additions & 0 deletions scripts/smoke.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ param(
)
$ErrorActionPreference = 'Stop'

# A native child can have a different current directory from the PowerShell location.
if ($Game -notmatch '^(?:[a-zA-Z]:[\\/]|[\\/]{2})') {
$Game = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Game)
}

if ($PSBoundParameters.ContainsKey('Title')) {
$Title = $Title.Trim()
# control, format and line/paragraph separator characters would split the line for pr_check.py
Expand Down
38 changes: 38 additions & 0 deletions scripts/test-smoke-relative-game.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Run with powershell.exe or pwsh.exe. A stand-in launcher resolves the game argument.
$ErrorActionPreference = 'Stop'
$smoke = Join-Path $PSScriptRoot 'smoke.ps1'
$temp = (Resolve-Path -LiteralPath ([IO.Path]::GetTempPath())).Path
$fixture = Join-Path $temp ('xcl-smoke-game-' + [guid]::NewGuid())
$game = Join-Path $fixture 'Game With Spaces'
$null = New-Item -ItemType Directory -Path $game -Force
try {
$xcl = Join-Path $fixture 'xcl.cmd'
@'
@echo off
if not exist "%~2\sentinel.txt" exit /b 51
echo Log: %~dp0xcl.log
'@ | Set-Content -LiteralPath $xcl -Encoding ascii
[IO.File]::WriteAllText((Join-Path $game 'sentinel.txt'), 'fixture')
[IO.File]::WriteAllText((Join-Path $fixture 'xcl.log'), "(1 frames shown, 1 PresentX calls)`n")
[IO.File]::WriteAllText((Join-Path $fixture 'report.json'), '{"d3d12":{"adapter":"Fixture GPU"}}')

$absolute = & $smoke -Game $game -Xcl $xcl -Seconds 1
Push-Location -LiteralPath $fixture
try { $relative = & $smoke -Game '.\Game With Spaces' -Xcl $xcl -Seconds 1 }
finally { Pop-Location }
Push-Location -LiteralPath $game
try { $dot = & $smoke -Game '.' -Xcl $xcl -Seconds 1 }
finally { Pop-Location }

$title = $absolute -split "`n" | Where-Object { $_ -like 'title:*' }
foreach ($block in @($relative, $dot)) {
if (($block -split "`n" | Where-Object { $_ -like 'title:*' }) -ne $title) {
throw 'The same game folder produced a different title hash.'
}
if ($block -notmatch 'frames shown: 1 \(PresentX 1\)') { throw 'Missing smoke result.' }
}
'smoke-relative-game: ok'
} finally {
$resolved = (Resolve-Path -LiteralPath $fixture).Path
if ((Split-Path -Parent $resolved) -eq $temp) { Remove-Item -LiteralPath $resolved -Recurse -Force }
}
Loading