Skip to content
Closed
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
4 changes: 4 additions & 0 deletions scripts/check_no_game_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

python3 -I scripts/check_no_game_data.py # every file `git ls-files` lists
python3 -I scripts/check_no_game_data.py PATH... # only these files
python3 -I scripts/check_no_game_data.py --help # this text

Explicit PATH inputs must be regular files, not directories or symlinks. A missing, unreadable or non-regular
explicit input is reported on stderr and causes exit 2 unless another input matches game data (exit 1).
Expand Down Expand Up @@ -312,6 +313,9 @@ def display(path):


def main(argv):
if argv and argv[0] in ("-h", "--help"):
print(__doc__.strip())
return 0
if argv:
paths = argv
else:
Expand Down
13 changes: 12 additions & 1 deletion scripts/play-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@
# is changed. LEONIDA_* variables already set win over the defaults below.
set -eu

usage() {
echo "usage: $0 /path/to/game_scarlett_master.exe [--series-x]"
echo
echo "LEONIDA_RUNTIME, LEONIDA_VKD3D and LEONIDA_WINEPREFIX choose the runtime, the bundled VKD3D-Proton and"
echo "the Wine prefix; LEONIDA_CACHE_DIR and LEONIDA_DATA_DIR the caches and saves."
}

if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
usage
exit 0
fi
if [ $# -lt 1 ]; then
echo "usage: $0 /path/to/game_scarlett_master.exe [--series-x]" >&2
usage >&2
exit 2
fi
game_exe=$1
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_game_wine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SELF=$ROOT/scripts/run_game_wine.sh

usage() {
cat <<'EOF'
Usage: scripts/run_game_wine.sh --build DIR --exe FILE --game-dir DIR --out DIR [options] [-- gta6rt arguments]
Usage: scripts/run_game_wine.sh --build DIR --exe FILE --game-dir DIR --shaders DIR --out DIR [options] [-- gta6rt arguments]

Runs `gta6rt.exe --run <exe>` once under Wine, headless or on this display, with sound off, a pinned Vulkan device,
a time limit and the startup and D3D12 traces on, then prints counts only. Every path comes from here or from the
Expand Down
7 changes: 7 additions & 0 deletions scripts/run_wine_session.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
# run_wine_tests.py does, so Proton's or UMU-Proton's files/bin/wine also works on a host without a
# system Wine. The wineserver is $WINESERVER, else the one next to $WINE, else wineserver on PATH.
set -e
if [[ ${1:-} == -h || ${1:-} == --help ]]; then
echo "usage: run_wine_session.sh COMMAND [ARG...]"
echo
echo "Runs COMMAND on the display that initialized the dedicated Wine prefix in WINEPREFIX, then stops that"
echo "prefix's Wine processes. WINE (default wine) and WINESERVER (default: the one next to WINE) choose the Wine."
exit 0
fi
: "${WINEPREFIX:?Set WINEPREFIX to a dedicated test prefix}"

wine=${WINE:-wine}
Expand Down
7 changes: 7 additions & 0 deletions tests/test_check_no_game_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ def write(self, name, data):
f.write(data)
return path

def test_help_prints_the_usage_and_checks_nothing(self):
result = run(["--help"])
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("python3 -I scripts/check_no_game_data.py PATH...", result.stdout)
self.assertIn("exits 2", result.stdout)
self.assertEqual(result.stderr, "")

def test_each_format_is_caught_under_another_name(self):
for name, data, fmt in CAUGHT:
with self.subTest(name=name):
Expand Down
34 changes: 34 additions & 0 deletions tests/test_play_linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""scripts/play-linux.sh answers --help with its usage, without a game executable, Wine or a prefix.

python -I tests/test_play_linux.py

The help path is checked alone: PATH holds nothing but the shell, and no LEONIDA_* variable is set, so a --help that
fell through to the game start would fail loudly instead of passing. POSIX only; no game files.
"""
import os
import shutil
import subprocess
import unittest
from pathlib import Path

SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "play-linux.sh"


@unittest.skipUnless(os.name == "posix" and shutil.which("sh"), "needs a POSIX shell")
class PlayLinuxHelp(unittest.TestCase):
def run_help(self, flag: str) -> subprocess.CompletedProcess:
return subprocess.run(["sh", str(SCRIPT), flag], env={"PATH": "/usr/bin:/bin"},
capture_output=True, text=True, timeout=60)

def test_help_prints_the_usage_and_starts_nothing(self):
for flag in ("-h", "--help"):
with self.subTest(flag=flag):
p = self.run_help(flag)
self.assertEqual(p.returncode, 0, p.stderr)
self.assertIn("usage:", p.stdout)
self.assertIn("--series-x", p.stdout)
self.assertEqual(p.stderr, "")


if __name__ == "__main__":
unittest.main()
2 changes: 2 additions & 0 deletions tests/test_run_game_wine.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def test_help_lists_the_inputs(self):
"--screenshot-every", "LEONIDA_SHADERS", "LEONIDA_GAME_EXE", "LEONIDA_AUDIO=silent",
"kwin_wayland", "DRI3"):
self.assertIn(word, p.stdout)
# The Usage line itself names every required input, not just the Inputs section below it.
self.assertIn("--shaders", p.stdout.splitlines()[0])

def test_a_missing_input_is_named(self):
for flag, word in (("--build", "--build is required"), ("--exe", "--exe (or LEONIDA_GAME_EXE)"),
Expand Down
7 changes: 7 additions & 0 deletions tests/test_run_wine_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def test_wineserver_override_and_path_fallback(self):
self.assertEqual(r.returncode, 0, r.stderr)
self.assertEqual(log.read_text().splitlines()[-1], f"{other / 'my-wineserver'} -k")

def test_help_needs_no_prefix_or_wine(self):
r = subprocess.run(["bash", str(SCRIPT), "--help"], env={"PATH": "/usr/bin:/bin"},
capture_output=True, text=True, timeout=60)
self.assertEqual(r.returncode, 0, r.stderr)
self.assertIn("WINEPREFIX", r.stdout)
self.assertEqual(r.stderr, "")

def test_missing_wine_is_reported(self):
with tempfile.TemporaryDirectory() as d:
root = Path(d)
Expand Down
Loading