Skip to content

Commit

Permalink
Add new wineserver args to protontricks-launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Matoking committed Feb 19, 2022
1 parent 88bc443 commit 6521829
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/protontricks/cli/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,30 @@ def main(args=None):
"--no-bwrap", action="store_true", default=False,
help="Disable bwrap containerization when using Steam Runtime"
)
parser.add_argument(
"--background-wineserver",
dest="background_wineserver",
action="store_true",
help=(
"Launch a background wineserver process to improve Wine command "
"startup time. Default if bwrap is enabled."
)
)
parser.add_argument(
"--no-background-wineserver",
dest="background_wineserver",
action="store_false",
help=(
"Do not launch a background wineserver process to improve Wine "
"command startup time. Default if bwrap is not enabled."
)
)
parser.add_argument(
"--appid", type=int, nargs="?", default=None
)
parser.add_argument("executable", type=str)
parser.add_argument("exec_args", nargs=argparse.REMAINDER)
parser.set_defaults(background_wineserver=None)

args = parser.parse_args(args)

Expand Down Expand Up @@ -136,6 +155,11 @@ def exit_(error):
if args.no_bwrap:
cli_args += ["--no-bwrap"]

if args.background_wineserver is True:
cli_args += ["--background-wineserver"]
elif args.background_wineserver is False:
cli_args += ["--no-background-wineserver"]

inner_args = " ".join(
["wine", "'{}'".format(str(executable_path))]
+ exec_args
Expand Down
33 changes: 33 additions & 0 deletions tests/cli/test_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,39 @@ def test_run_executable_passthrough_arguments(
assert cli_args[4].endswith("test.exe'")
assert cli_args[5] == "10"

@pytest.mark.parametrize("argument", [
None,
"--background-wineserver",
"--no-background-wineserver"
])
def test_run_executable_passthrough_background_wineserver(
self, launch_cli, monkeypatch, steam_app_factory,
argument):
"""
Try running an EXE file and apply given wineserver argument.
If the argument is set, it should also be passed to the main
entrypoint.
"""
cli_args = []

monkeypatch.setattr(
"protontricks.cli.launch.cli_main",
cli_args.extend
)

steam_app_factory(name="Fake game", appid=10)

extra_args = [argument] if argument else []
launch_cli(extra_args + ["--appid", "10", "test.exe"])

if argument:
# Ensure the corresponding argument was passd to the main CLI
# entrypoint
assert argument in cli_args
else:
assert "--background-wineserver" not in cli_args
assert "--no-background-wineserver" not in cli_args

def test_cli_error_handler_uncaught_exception(
self, launch_cli, default_proton, steam_app_factory, monkeypatch,
gui_provider):
Expand Down

0 comments on commit 6521829

Please sign in to comment.