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: 1 addition & 1 deletion d3d12/scripts/play-nvidia.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ $settings.LEONIDA_MENU_CONSOLE = $console
$settings.LEONIDA_MENU_FILE = $menuFile
$settings.LEONIDA_MENU_PLAY = $MyInvocation.MyCommand.Path
$again = @("-Exe '$($Exe -replace "'", "''")'", "-Build $Build")
foreach ($s in 'NoSmoothMotion', 'NoDlss', 'SeriesX', 'Quality', 'RayTracing', 'FsrFrameGen', 'NoPrecompile', 'Log', 'Capture') {
foreach ($s in 'NoSmoothMotion', 'MotionBlur', 'NoDlss', 'SeriesX', 'Quality', 'RayTracing', 'FsrFrameGen', 'NoPrecompile', 'Log', 'Capture') {
if ($PSBoundParameters[$s]) { $again += "-$s" }
}
foreach ($s in 'Resolution', 'Lowest', 'Dlss', 'FrameGen', 'Aspect', 'PresentScale', 'Adapter', 'DlssDir', 'StreamlineDir', 'FidelityFxDir') {
Expand Down
50 changes: 49 additions & 1 deletion tests/test_win_launchers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for Build.bat and Mods.bat quoted per-user Python lookup and non-interactive pause control.
"""Tests for the Windows launchers.

python -I tests/test_win_launchers.py
"""
Expand All @@ -14,6 +14,8 @@
ROOT = Path(__file__).resolve().parents[1]
BUILD_BAT = ROOT / "Build.bat"
MODS_BAT = ROOT / "Mods.bat"
NVIDIA_LAUNCHER = ROOT / "d3d12" / "scripts" / "play-nvidia.ps1"
POWERSHELL = shutil.which("pwsh") or shutil.which("powershell.exe")

FAKE_PY_CS = r"""
using System;
Expand All @@ -37,6 +39,52 @@


class WinLaunchersTests(unittest.TestCase):
@unittest.skipUnless(POWERSHELL, "requires PowerShell")
def test_nvidia_menu_restart_preserves_motion_blur_switch(self) -> None:
with tempfile.TemporaryDirectory() as td:
root = Path(td)
scripts = root / "scripts"
scripts.mkdir()
launcher = scripts / NVIDIA_LAUNCHER.name
shutil.copyfile(NVIDIA_LAUNCHER, launcher)
executable = root / "synthetic title.exe"
executable.touch()

command = r"""
$ErrorActionPreference = 'Stop'
function Get-CimInstance {
param([string]$ClassName)
if ($ClassName -ne 'Win32_OperatingSystem') { throw "Unexpected CIM query: $ClassName" }
[pscustomobject]@{ BuildNumber = '26100' }
}
$options = @{
Exe = $env:TEST_NVIDIA_EXE
DryRun = $true
NoDlss = $true
NoPrecompile = $true
WindowsBarMB = 0
}
& $env:TEST_NVIDIA_LAUNCHER @options -MotionBlur
& $env:TEST_NVIDIA_LAUNCHER @options -MotionBlur:$false
& $env:TEST_NVIDIA_LAUNCHER @options
"""
env = {name: value for name, value in os.environ.items() if not name.upper().startswith("LEONIDA_")}
env.update(TEST_NVIDIA_LAUNCHER=str(launcher), TEST_NVIDIA_EXE=str(executable))
result = subprocess.run(
[POWERSHELL, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", command],
env=env,
check=True,
capture_output=True,
encoding="utf-8",
errors="replace",
timeout=30,
)
restart_args = [line for line in result.stdout.splitlines() if line.startswith("LEONIDA_MENU_ARGS=")]
self.assertEqual(len(restart_args), 3, result.stdout)
self.assertRegex(restart_args[0], r"(?:^| )-MotionBlur(?: |$)")
for args in restart_args[1:]:
self.assertNotRegex(args, r"(?:^| )-MotionBlur(?: |$)")

def test_static_quoting_and_no_pause_guards(self) -> None:
build_txt = BUILD_BAT.read_text(encoding="utf-8")
mods_txt = MODS_BAT.read_text(encoding="utf-8")
Expand Down