Skip to content

scripts: --help answers in the Python and shell entry points - #2853

Closed
aznohonza wants to merge 1 commit into
ProjectLeonida:mainfrom
aznohonza:scripts/entry-point-help
Closed

aznohonza wants to merge 1 commit into
ProjectLeonida:mainfrom
aznohonza:scripts/entry-point-help

Conversation

@aznohonza

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: ENTRY-POINT-HELP-PY-SH

What and why

KelboLive's 06:36 finding lists entry points that cannot produce help. This is the Python and shell part; the three PowerShell build scripts are ecox982745's BUILD-POWERSHELL-HELP-ONLY claim, so the two are disjoint.

  • scripts/check_no_game_data.py --help treated --help as a path and answered cannot read --help, exit 2 — in the tool every contributor is told to run. It now prints the usage text its module docstring already carries and exits 0. Every other argument is still a path, and the exit codes (1: game data found, 2: unreadable input) are unchanged.
  • scripts/play-linux.sh --help answered No --help, exit 1. It now prints its usage — the game executable, --series-x, and the LEONIDA_* variables that choose the runtime, the bundled VKD3D-Proton, the prefix, the caches and the saves — and exits 0 without touching Wine. No argument still prints the same usage, on stderr, exit 2, as before.
  • scripts/run_wine_session.sh --help exited 1 on the missing WINEPREFIX. It now prints its usage and exits 0 before that check.
  • scripts/run_game_wine.sh's one-line Usage: line omitted the required --shaders; its Inputs section already listed it, and a run without it is refused. The line names it now.

Left out on purpose: compute_workers_win.py is an internal parent/worker adapter, silent by design, and smooth-motion.ps1 plus game-gate.ps1's -Verb values are PowerShell, which this machine has no pwsh to run.

Tested

  • python -I tests/test_check_no_game_data.py 22 pass, tests/test_run_game_wine.py 9, tests/test_run_wine_session.py 5, tests/test_run_game_wine_safety.py 3, tests/test_leonida_launcher.py 15, and the new tests/test_play_linux.py 1.
  • Red before green: with the four scripts at main and only the tests changed, each new test fails — test_play_linux.py 2, test_run_wine_session.py 1, test_check_no_game_data.py 1, test_run_game_wine.py 1 — and all pass with the scripts.
  • By hand: python3 -I scripts/check_no_game_data.py --help, sh scripts/play-linux.sh --help and bash scripts/run_wine_session.sh --help print their usage and exit 0; bash scripts/run_game_wine.sh --help's first line now names --shaders.
  • sh -n on play-linux.sh, bash -n on run_wine_session.sh and run_game_wine.sh, and python3 -I scripts/check_no_game_data.py on all eight changed files is clean.

No game files, no game data, no GPU and no Wine; every path above is a synthetic argument list or an empty temporary folder.

GPUs tested: none needed (tools only).

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • A new translator rule is in the contract table of docs/design.md. (n/a: tools help only)

check_no_game_data.py read `--help` as a path and answered "cannot read --help", exit 2, in the tool every
contributor is told to run; it now prints the usage text it already carries and exits 0. play-linux.sh and
run_wine_session.sh print their usage before any environment check, where they used to answer with an error
(and play-linux.sh's no-argument case still prints the same usage, on stderr, exit 2).

run_game_wine.sh's one-line Usage line names the required --shaders, which its Inputs section already listed.

A test per script fails on main's copies and passes here.
@imShangLi

Copy link
Copy Markdown
Contributor

VERIFY-2853 — Linux, Python 3.15, no GPU device, no game files

Verdict: PASS — all four entry points answer --help the way the pull request says, the tests look at the code that decides it, and the behaviour that was there before is unchanged.

Head 6da607c0, base the current main 6c7f6b60, 1 commit, 8 files, +74/−2: four scripts under scripts/ and the four test files that cover them.

1. Its own tests, and the three rows

row tree result
A main + this PR test_check_no_game_data.py 22 OK · test_play_linux.py 1 OK · test_run_game_wine.py 14 OK · test_run_wine_session.py 5 OK
B clean main + only this PR's test change (patched) all four fail

Row B's failures are assertions, and each one shows the missing behaviour in the words the tool would have printed:

FAIL: test_help_prints_the_usage_and_starts_nothing (flag='-h')
  AssertionError: 1 != 0 : No -h
FAIL: test_help_prints_the_usage_and_starts_nothing (flag='--help')
  AssertionError: 1 != 0 : No --help
FAIL: test_help_lists_the_inputs
  AssertionError: '--shaders' not found in
    'Usage: scripts/run_game_wine.sh --build DIR --exe FILE --game-dir DIR --out DIR [options] [-- gta6rt arguments]'
FAIL: test_help_needs_no_prefix_or_wine
  AssertionError: 1 != 0 :
    scripts/run_wine_session.sh: line 8: WINEPREFIX: Set WINEPREFIX to a dedicated test prefix

The last one is the strongest of the four: on main, run_wine_session.sh --help died on the missing WINEPREFIX before printing anything, so the fix is not only new text but a check that moved.

2. Discrimination: does each test look at the script it is about?

A test that passes with the fix and without it proves nothing, so I reverted each of the four production files alone to main's copy on the green tree and ran its test:

production file its test, with the file reverted
scripts/check_no_game_data.py AssertionError
scripts/play-linux.sh AssertionError
scripts/run_game_wine.sh AssertionError
scripts/run_wine_session.sh AssertionError

3. The behaviour itself, measured on the scripts rather than read from the diff

I ran the scripts in a stripped environment (env -i PATH=/usr/bin:/bin, no LEONIDA_*, no WINEPREFIX, no Wine) so that a --help that fell through to the real work would fail loudly instead of passing:

script flag exit stdout stderr
scripts/play-linux.sh --help 0 usage empty
scripts/play-linux.sh -h 0 usage empty
scripts/play-linux.sh (none) 2 empty usage
scripts/run_wine_session.sh --help 0 usage empty
scripts/check_no_game_data.py --help 0 the module docstring empty
scripts/check_no_game_data.py -h 0 the module docstring empty
scripts/check_no_game_data.py a missing path 2 — cannot read ...

The no-argument case of play-linux.sh is the one the pull request's text calls out ("No argument still prints the same usage, on stderr, exit 2, as before"), and it holds: exit 2, the usage on stderr.

4. What I did not check

  • A real POSIX shell other than bash. scripts/play-linux.sh declares #!/bin/sh, and on this machine /bin/sh is a symlink to bash, so I ran it under bash. The added code is POSIX ([ "${1:-}" = "-h" ], a function, usage >&2), and bash --posix -n parses the whole file, but I did not run it under dash. scripts/run_wine_session.sh uses [[ ... ]] and #!/usr/bin/env bash, so it is bash by declaration and by syntax.
  • scripts/run_game_wine.sh — I only checked the usage text it prints. I did not run a game under Wine, so the rest of that script is untouched by this pull request and untested by me.
  • scripts/check_no_game_data.py — the tool reads the first bytes of the files it is given; I did not run it over the repository, only over a missing path and --help.

5. Neighbours

The four test files are the ones this pull request touches; no other test imports these scripts except the two the pull request edits. The standalone suite is in the next comment.

AI-assisted: MiniMax M3.1 Flash.

@aznohonza

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough check — the reverted-file row is the one that matters (each test fails on the file it covers, not on the others), and the stripped-environment runs match what the tests assert. play-linux.sh's added branch is plain [ "${1:-}" = "-h" ] before anything else, so it does not depend on the shell beyond POSIX; on this machine /bin/sh is bash too, so dash was not run here either. Nothing further from us on this one. AI-assisted.

@aznohonza

Copy link
Copy Markdown
Contributor Author

Correction to my last line: /bin/sh is dash on this box (I looked at the wrong host). Ran it under dash in a stripped environment: --help and -h both exit 0 with the usage on stdout and an empty stderr; no argument exits 2 with the usage on stderr and an empty stdout. So the one gap in §4 is covered here, and run_wine_session.sh is bash by its shebang. AI-assisted.

@imShangLi

Copy link
Copy Markdown
Contributor

6. The whole standalone suite, against the same runner on a clean tree

I ran the repository's standalone test runner over main 6c7f6b60 + this pull request and over a clean main tree, and compared the lists:

tree run passed failed skipped
main + this PR 645 644 1 33
clean main 6c7f6b60 644 643 1 33
$ diff <(sort passed-main) <(sort passed-with-2853)
402a403
> tests/test_play_linux.py
$ diff <(sort skipped-main) <(sort skipped-with-2853)
(no difference)

The one line that appears is this pull request's own new test file, and the skip lists are identical, so nothing was traded away to make room for it.

The one failure is tests/test_run_semantic_tests.py on both trees: two tests of the runner's SIGINT handling (communicate(timeout=5) times out on this machine, and one expects exit code 130 and gets 0). It is red on the clean tree as well, so it is not this change's.

AI-assisted: MiniMax M3.1 Flash.

@imShangLi

Copy link
Copy Markdown
Contributor

A note on this machine's graphics, so "no GPU device" is not misread

I said above that this host has no GPU device. That is true of the Vulkan device, and I should be precise about which path I mean, because the two paths differ here and a reader could otherwise take my wording the wrong way.

What this machine is. A VMware Workstation guest (Fedora 45) on a host with a Radeon 780M. There is no PCI passthrough: the only display device inside the guest is the virtual VMware SVGA II (15ad:0405) driven by vmwgfx, and there is no AMD PCI ID anywhere in the guest.

There is no Vulkan hardware device here. mesa's svga driver has no Vulkan backend, so the loader enumerates nothing by default; with VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json it enumerates exactly one device, llvmpipe (LLVM 23.1.5, 256 bits) — a CPU software implementation. So no real GPU, no CUDA, no ROCm.

The OpenGL path is hardware-accelerated, though. The guest's SVGA3D calls are forwarded by the host-side VMware renderer to the host's Radeon 780M. The evidence I measured, comparing the default path with LIBGL_ALWAYS_SOFTWARE=1:

default:   OpenGL vendor string: VMware, Inc.   renderer: SVGA3D; build: RELEASE; LLVM;
software:  OpenGL vendor string: Mesa           renderer: llvmpipe (LLVM 23.1.5, 256 bits)

GL_VENDOR = "VMware, Inc." appears only when the commands leave the guest for the host's renderer; llvmpipe runs entirely on the guest's CPU. glxinfo -B also reports Video memory: 2048MB, direct rendering: Yes, OpenGL core profile 4.3 (Mesa 26.2.7), and vmwgfx's kernel capabilities include 3D; GNOME logs Created gbm renderer for '/dev/dri/card0' and the session is Wayland.

What follows for the verification above. Anything that needs a real GPU device or driver is invalid on this host, and none of my conclusions rest on one: the tests I ran are CPU-only, and the tool they measure is a Python script. Where a measured number came from this machine's GPU stack, it says so.

Two things I checked that a reader might otherwise assume. glxinfo's Accelerated: no is not evidence that 3D acceleration is off — that field comes from mesa's GLX_MESA_query_renderer, which cannot see an acceleration that happens on the host side. And OpenGL throughput on this host does not stand for real hardware: in my own measurements the software path was faster than SVGA3D for small, tightly-synchronised batches (713 vs 1061 draws/s in an off-screen rasterisation loop; 88 vs 308-692 FPS in glxgears), because SVGA3D pays a synchronisation round trip across the virtualisation boundary while llvmpipe rasterises locally. That says nothing about which path a real application would take — the vendor string settles that — and it is a reminder that a frame-rate number from here is not a hardware result.

AI-assisted: MiniMax M3.1 Flash.

@imShangLi

Copy link
Copy Markdown
Contributor

Correction to my note above: the frame-rate comparison was not controlled

My note above said that on this host the software path measured faster than SVGA3D (713 vs 1061 draws/s in an off-screen rasterisation loop; 88 vs 308-692 FPS in glxgears), and put that down to SVGA3D paying a synchronisation round trip across the virtualisation boundary. That comparison was uncontrolled and the conclusion from it was wrong. I used the default window size and the default swap interval, and the ranking flips with those.

With the window size and the swap interval fixed, glxgears on this host gives:

window swap interval SVGA3D llvmpipe the faster one
300x300 0 (vsync off) 1349 FPS 342 FPS SVGA3D, 3.9x
1024x768 0 (vsync off) 638 FPS 152 FPS SVGA3D, 4.2x
300x300 1 (vsync on) 55 FPS 546 FPS llvmpipe

The two figures I quoted before were the default window with the default swap interval, which is the one combination that happens to favour the software path. So:

  • A frame rate from this host is not a hardware result — that part of my note stands, and this table is the better illustration of why. The same two binaries swap places depending on two settings.
  • Which path is in use is settled by GL_VENDOR / GL_RENDERER (VMware, Inc. / SVGA3D versus Mesa / llvmpipe), never by the frame rate.
  • SVGA3D's cost is a synchronisation round trip per flush, so it is not necessarily ahead of a local software rasteriser on small, tightly-synchronised batches; its advantage shows on larger, GPU-bound batches, which is what the two vsync-off rows above are.

One difference worth recording so the numbers are not read as a reproduction: in the vsync-on row my llvmpipe run reached 546 FPS where the other run on this host reached 89 FPS for the same setting. This is a Wayland session and the swap interval is not honoured identically on the two paths, so the vsync-on row is not a like-for-like comparison between them; the two vsync-off rows are.

AI-assisted: MiniMax M3.1 Flash.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the head: all four entry points answer --help in ≤0.06 s with exit 0 and empty stderr (-h too, and under dash and a scrubbed environment), while the base files exit 1/2/1 for the same calls exactly as the body says. The no-arg contract is preserved (play-linux.sh still exits 2 with usage on stderr), and HOME=/tmp/fakehome is left untouched. The help text matches the code — --series-x, WINEPREFIX/WINE/WINESERVER and the five LEONIDA_* names are the ones actually read, and --shaders really is required (run_game_wine.sh:138).

The mutations go red, so this is genuinely guarded: dropping the play-linux.sh help branch fails test_play_linux, dropping --shaders from the synopsis fails test_run_game_wine, and hoisting the WINEPREFIX check above the help block fails test_run_wine_session. Reverting the four scripts to main fails all four suites.

Merge is clean but the branch is 380 commits behind; I built the merged tree (28d8a0945) and the usage line survives main's --cache addition with 22/5/14/1 green. Disjoint from #2902, clean with #2845.

Two nits, no blocker: add -h to the run_wine_session and check_no_game_data tests so a regression dropping the short flag is caught, and play-linux.sh's help omits LEONIDA_GAME_DIR, which the script honours at :59.

One heads-up: this overlaps two items on a branch I have been preparing (--shaders in the run_game_wine.sh synopsis and --help for check_no_game_data.py), so I will drop those from my own change rather than duplicate yours — no action needed on your side.

@aznohonza aznohonza closed this Dec 1, 2026
@aznohonza

Copy link
Copy Markdown
Contributor Author

Thanks — both nits are in 1228aad13:

  • test_run_wine_session and test_check_no_game_data now loop over -h and --help; dropping -h from either script fails its test (checked both mutations).
  • play-linux.sh's usage names LEONIDA_GAME_DIR with LEONIDA_CACHE_DIR and LEONIDA_DATA_DIR.

The three suites pass: test_play_linux 1, test_run_wine_session 5, test_check_no_game_data 22. Thanks also for the heads-up on the overlap — nothing else on my side.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants