From 18d6817af3786fa8570c8c8a0fe56c54ae4a6f14 Mon Sep 17 00:00:00 2001 From: luckyteagirl <290248872+luckyteagirl@users.noreply.github.com> Date: Thu, 26 Nov 2026 00:24:53 -0800 Subject: [PATCH] Scripts: preserve trailing backslashes in native smoke paths Escape terminal backslashes before the closing quote for the native launcher. Verify what a real executable receives for paths with spaces and a drive root. Assisted-by: OpenAI Codex (GPT-6.2 Sol) --- scripts/smoke-native-arguments.tests.ps1 | 38 ++++++++++++++++++++++++ scripts/smoke.ps1 | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 scripts/smoke-native-arguments.tests.ps1 diff --git a/scripts/smoke-native-arguments.tests.ps1 b/scripts/smoke-native-arguments.tests.ps1 new file mode 100644 index 0000000000..56a81aa93c --- /dev/null +++ b/scripts/smoke-native-arguments.tests.ps1 @@ -0,0 +1,38 @@ +# Run with powershell.exe or pwsh.exe. Python stands in for native xcl.exe. +$ErrorActionPreference = 'Stop' +$smoke = Join-Path $PSScriptRoot 'smoke.ps1' +$python = (Get-Command python.exe -CommandType Application | Select-Object -First 1).Source +$temp = (Resolve-Path -LiteralPath ([IO.Path]::GetTempPath())).ProviderPath +$fixture = Join-Path $temp ('xcl-smoke-native-' + [guid]::NewGuid()) +$originalDirectory = [Environment]::CurrentDirectory +$null = New-Item -ItemType Directory -Path $fixture +try { + $game = Join-Path $fixture 'Mock Game' + $null = New-Item -ItemType Directory -Path $game + $received = Join-Path $fixture 'argv.json' + [IO.File]::WriteAllText((Join-Path $fixture 'xcl.log'), '(1 frames shown, 1 PresentX calls)') + [IO.File]::WriteAllText((Join-Path $fixture 'report.json'), '{"d3d12":{"adapter":"Synthetic"}}') + [IO.File]::WriteAllText((Join-Path $fixture 'run'), @' +import json +import sys +from pathlib import Path + +assert len(sys.argv) == 2, sys.argv +Path("argv.json").write_text(json.dumps(sys.argv[1]), encoding="ascii") +print("Log: " + str(Path("xcl.log").resolve())) +'@) + + [Environment]::CurrentDirectory = $fixture + $driveRoot = [IO.Path]::GetPathRoot($fixture) + $failures = foreach ($path in @($game, ($game + '\'), ($game + '\\'), $driveRoot)) { + $null = & $smoke -Game $path -Title 'Synthetic argv' -Xcl $python -Seconds 1 + $actual = Get-Content -LiteralPath $received -Raw | ConvertFrom-Json + if ($actual -cne $path) { "expected [$path], received [$actual]" } + } + if ($failures) { throw ($failures -join "`n") } + 'smoke-native-arguments: ok' +} finally { + [Environment]::CurrentDirectory = $originalDirectory + $resolved = (Resolve-Path -LiteralPath $fixture).ProviderPath + if ((Split-Path -Parent $resolved) -eq $temp) { Remove-Item -LiteralPath $resolved -Recurse -Force } +} diff --git a/scripts/smoke.ps1 b/scripts/smoke.ps1 index db296218b2..9253d68955 100644 --- a/scripts/smoke.ps1 +++ b/scripts/smoke.ps1 @@ -43,7 +43,8 @@ if ($Xcl -match '\.(cmd|bat)$') { $psi.Arguments = '/c ""' + $Xcl + '" run "' + $Game + '""' } else { $psi.FileName = $Xcl - $psi.Arguments = 'run "' + $Game + '"' + # Double trailing backslashes so the native parser treats the closing quote as a delimiter. + $psi.Arguments = 'run "' + ($Game -replace '(\\+)\z', '$1$1') + '"' } $psi.UseShellExecute = $false $psi.CreateNoWindow = $true