mirror of
https://github.com/tcsenpai/UWINE.git
synced 2025-06-06 19:45:20 +00:00
Rename gamelauncher files
This commit is contained in:
parent
e1414dd460
commit
d6eb1c8484
@ -7,7 +7,7 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import tomllib
|
import tomllib
|
||||||
from typing import Dict, Any, List, Set, Union
|
from typing import Dict, Any, List, Set, Union
|
||||||
import gamelauncher_plugins
|
import ulwgl_plugins
|
||||||
from re import match
|
from re import match
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ def main() -> None: # noqa: D103
|
|||||||
set_env(env, args)
|
set_env(env, args)
|
||||||
|
|
||||||
# Game Drive
|
# Game Drive
|
||||||
gamelauncher_plugins.enable_steam_game_drive(env)
|
ulwgl_plugins.enable_steam_game_drive(env)
|
||||||
|
|
||||||
# Set all environment variables
|
# Set all environment variables
|
||||||
# NOTE: `env` after this block should be read only
|
# NOTE: `env` after this block should be read only
|
@ -1,5 +1,5 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import gamelauncher
|
import ulwgl_run
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
@ -8,11 +8,11 @@ from pathlib import Path
|
|||||||
from tomllib import TOMLDecodeError
|
from tomllib import TOMLDecodeError
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
import re
|
import re
|
||||||
import gamelauncher_plugins
|
import ulwgl_plugins
|
||||||
|
|
||||||
|
|
||||||
class TestGameLauncher(unittest.TestCase):
|
class TestGameLauncher(unittest.TestCase):
|
||||||
"""Test suite for gamelauncher.py.
|
"""Test suite for ulwgl_run.py.
|
||||||
|
|
||||||
TODO: test for mutually exclusive options
|
TODO: test for mutually exclusive options
|
||||||
"""
|
"""
|
||||||
@ -79,15 +79,15 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
os.environ["STORE"] = self.test_file
|
os.environ["STORE"] = self.test_file
|
||||||
# Args
|
# Args
|
||||||
args = gamelauncher.parse_args()
|
args = ulwgl_run.parse_args()
|
||||||
# Config
|
# Config
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
# Prefix
|
# Prefix
|
||||||
gamelauncher.setup_pfx(self.env["WINEPREFIX"])
|
ulwgl_run.setup_pfx(self.env["WINEPREFIX"])
|
||||||
# Env
|
# Env
|
||||||
gamelauncher.set_env(self.env, args)
|
ulwgl_run.set_env(self.env, args)
|
||||||
# Game drive
|
# Game drive
|
||||||
result_gamedrive = gamelauncher_plugins.enable_steam_game_drive(self.env)
|
result_gamedrive = ulwgl_plugins.enable_steam_game_drive(self.env)
|
||||||
|
|
||||||
for key, val in self.env.items():
|
for key, val in self.env.items():
|
||||||
os.environ[key] = val
|
os.environ[key] = val
|
||||||
@ -144,27 +144,27 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
# Config
|
# Config
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
# Prefix
|
# Prefix
|
||||||
gamelauncher.setup_pfx(self.env["WINEPREFIX"])
|
ulwgl_run.setup_pfx(self.env["WINEPREFIX"])
|
||||||
# Env
|
# Env
|
||||||
gamelauncher.set_env(self.env, result)
|
ulwgl_run.set_env(self.env, result)
|
||||||
# Game drive
|
# Game drive
|
||||||
gamelauncher_plugins.enable_steam_game_drive(self.env)
|
ulwgl_plugins.enable_steam_game_drive(self.env)
|
||||||
|
|
||||||
for key, val in self.env.items():
|
for key, val in self.env.items():
|
||||||
os.environ[key] = val
|
os.environ[key] = val
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
with self.assertRaisesRegex(FileNotFoundError, "proton"):
|
with self.assertRaisesRegex(FileNotFoundError, "proton"):
|
||||||
gamelauncher.build_command(self.env, test_command)
|
ulwgl_run.build_command(self.env, test_command)
|
||||||
|
|
||||||
def test_build_command_toml(self):
|
def test_build_command_toml(self):
|
||||||
"""Test build_command.
|
"""Test build_command.
|
||||||
@ -192,26 +192,26 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
# Config
|
# Config
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
# Prefix
|
# Prefix
|
||||||
gamelauncher.setup_pfx(self.env["WINEPREFIX"])
|
ulwgl_run.setup_pfx(self.env["WINEPREFIX"])
|
||||||
# Env
|
# Env
|
||||||
gamelauncher.set_env(self.env, result)
|
ulwgl_run.set_env(self.env, result)
|
||||||
# Game drive
|
# Game drive
|
||||||
gamelauncher_plugins.enable_steam_game_drive(self.env)
|
ulwgl_plugins.enable_steam_game_drive(self.env)
|
||||||
|
|
||||||
for key, val in self.env.items():
|
for key, val in self.env.items():
|
||||||
os.environ[key] = val
|
os.environ[key] = val
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
test_command_result = gamelauncher.build_command(self.env, test_command)
|
test_command_result = ulwgl_run.build_command(self.env, test_command)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
test_command_result is test_command, "Expected the same reference"
|
test_command_result is test_command, "Expected the same reference"
|
||||||
)
|
)
|
||||||
@ -249,21 +249,21 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
os.environ["STORE"] = self.test_file
|
os.environ["STORE"] = self.test_file
|
||||||
# Args
|
# Args
|
||||||
result_args = gamelauncher.parse_args()
|
result_args = ulwgl_run.parse_args()
|
||||||
# Config
|
# Config
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
# Prefix
|
# Prefix
|
||||||
gamelauncher.setup_pfx(self.env["WINEPREFIX"])
|
ulwgl_run.setup_pfx(self.env["WINEPREFIX"])
|
||||||
# Env
|
# Env
|
||||||
gamelauncher.set_env(self.env, result_args)
|
ulwgl_run.set_env(self.env, result_args)
|
||||||
# Game drive
|
# Game drive
|
||||||
gamelauncher_plugins.enable_steam_game_drive(self.env)
|
ulwgl_plugins.enable_steam_game_drive(self.env)
|
||||||
|
|
||||||
for key, val in self.env.items():
|
for key, val in self.env.items():
|
||||||
os.environ[key] = val
|
os.environ[key] = val
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
test_command = gamelauncher.build_command(self.env, test_command)
|
test_command = ulwgl_run.build_command(self.env, test_command)
|
||||||
self.assertIsInstance(test_command, list, "Expected a List from build_command")
|
self.assertIsInstance(test_command, list, "Expected a List from build_command")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(test_command), 7, "Expected 7 elements in the list from build_command"
|
len(test_command), 7, "Expected 7 elements in the list from build_command"
|
||||||
@ -290,19 +290,19 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
test_file = "foo.toml"
|
test_file = "foo.toml"
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=test_file),
|
return_value=argparse.Namespace(config=test_file),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
with self.assertRaisesRegex(FileNotFoundError, test_file):
|
with self.assertRaisesRegex(FileNotFoundError, test_file):
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
|
|
||||||
def test_set_env_toml_opts_nofile(self):
|
def test_set_env_toml_opts_nofile(self):
|
||||||
"""Test set_env_toml for options that are a file.
|
"""Test set_env_toml for options that are a file.
|
||||||
@ -328,18 +328,18 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
|
|
||||||
# Check if its the TOML file we just created
|
# Check if its the TOML file we just created
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
@ -370,19 +370,19 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
with self.assertRaisesRegex(FileNotFoundError, "exe"):
|
with self.assertRaisesRegex(FileNotFoundError, "exe"):
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
|
|
||||||
def test_set_env_toml_err(self):
|
def test_set_env_toml_err(self):
|
||||||
"""Test set_env_toml for valid TOML.
|
"""Test set_env_toml for valid TOML.
|
||||||
@ -406,18 +406,18 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
# Env
|
# Env
|
||||||
with self.assertRaisesRegex(TOMLDecodeError, "Invalid"):
|
with self.assertRaisesRegex(TOMLDecodeError, "Invalid"):
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
|
|
||||||
def test_set_env_toml_nodir(self):
|
def test_set_env_toml_nodir(self):
|
||||||
"""Test set_env_toml if certain key/value are not a dir.
|
"""Test set_env_toml if certain key/value are not a dir.
|
||||||
@ -441,19 +441,19 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
with self.assertRaisesRegex(NotADirectoryError, "proton"):
|
with self.assertRaisesRegex(NotADirectoryError, "proton"):
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
|
|
||||||
def test_set_env_toml_tables(self):
|
def test_set_env_toml_tables(self):
|
||||||
"""Test set_env_toml for expected tables.
|
"""Test set_env_toml for expected tables.
|
||||||
@ -477,19 +477,19 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
with self.assertRaisesRegex(ValueError, "ulwgl"):
|
with self.assertRaisesRegex(ValueError, "ulwgl"):
|
||||||
gamelauncher.set_env_toml(self.env, result)
|
ulwgl_run.set_env_toml(self.env, result)
|
||||||
|
|
||||||
def test_set_env_toml_paths(self):
|
def test_set_env_toml_paths(self):
|
||||||
"""Test set_env_toml when specifying unexpanded file path values in the config file.
|
"""Test set_env_toml when specifying unexpanded file path values in the config file.
|
||||||
@ -538,18 +538,18 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
result_set_env = gamelauncher.set_env_toml(self.env, result)
|
result_set_env = ulwgl_run.set_env_toml(self.env, result)
|
||||||
self.assertTrue(result_set_env is self.env, "Expected the same reference")
|
self.assertTrue(result_set_env is self.env, "Expected the same reference")
|
||||||
|
|
||||||
# Check that the paths are still in the unexpanded form after setting the env
|
# Check that the paths are still in the unexpanded form after setting the env
|
||||||
@ -592,18 +592,18 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
file.write(toml_str)
|
file.write(toml_str)
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=toml_path),
|
return_value=argparse.Namespace(config=toml_path),
|
||||||
):
|
):
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
self.assertTrue(vars(result).get("config"), "Expected a value for --config")
|
||||||
# Env
|
# Env
|
||||||
result_set_env = gamelauncher.set_env_toml(self.env, result)
|
result_set_env = ulwgl_run.set_env_toml(self.env, result)
|
||||||
self.assertTrue(result_set_env is self.env, "Expected the same reference")
|
self.assertTrue(result_set_env is self.env, "Expected the same reference")
|
||||||
self.assertTrue(self.env["EXE"], "Expected EXE to be set")
|
self.assertTrue(self.env["EXE"], "Expected EXE to be set")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -633,7 +633,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
result = None
|
result = None
|
||||||
test_str = "foo"
|
test_str = "foo"
|
||||||
|
|
||||||
# Replicate the usage WINEPREFIX= PROTONPATH= GAMEID= STORE= PROTON_VERB= gamelauncher ...
|
# Replicate the usage WINEPREFIX= PROTONPATH= GAMEID= STORE= PROTON_VERB= ulwgl_run ...
|
||||||
with patch("sys.argv", ["", self.test_exe]):
|
with patch("sys.argv", ["", self.test_exe]):
|
||||||
os.environ["WINEPREFIX"] = self.test_file
|
os.environ["WINEPREFIX"] = self.test_file
|
||||||
os.environ["PROTONPATH"] = self.test_file
|
os.environ["PROTONPATH"] = self.test_file
|
||||||
@ -641,16 +641,16 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["STORE"] = test_str
|
os.environ["STORE"] = test_str
|
||||||
os.environ["PROTON_VERB"] = self.test_verb
|
os.environ["PROTON_VERB"] = self.test_verb
|
||||||
# Args
|
# Args
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
result[0:], "./tmp.WMYQiPb9A/foo", "Expected EXE to be unexpanded"
|
result[0:], "./tmp.WMYQiPb9A/foo", "Expected EXE to be unexpanded"
|
||||||
)
|
)
|
||||||
# Check
|
# Check
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
# Prefix
|
# Prefix
|
||||||
gamelauncher.setup_pfx(self.env["WINEPREFIX"])
|
ulwgl_run.setup_pfx(self.env["WINEPREFIX"])
|
||||||
# Env
|
# Env
|
||||||
result = gamelauncher.set_env(self.env, result[0:])
|
result = ulwgl_run.set_env(self.env, result[0:])
|
||||||
self.assertTrue(result is self.env, "Expected the same reference")
|
self.assertTrue(result is self.env, "Expected the same reference")
|
||||||
|
|
||||||
path_exe = Path(self.test_exe).expanduser().as_posix()
|
path_exe = Path(self.test_exe).expanduser().as_posix()
|
||||||
@ -692,7 +692,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
Path(self.test_file).cwd().as_posix() + "/" + self.test_file
|
Path(self.test_file).cwd().as_posix() + "/" + self.test_file
|
||||||
).as_posix(),
|
).as_posix(),
|
||||||
)
|
)
|
||||||
result = gamelauncher.setup_pfx(unexpanded_path)
|
result = ulwgl_run.setup_pfx(unexpanded_path)
|
||||||
|
|
||||||
# Replaces the expanded path to unexpanded
|
# Replaces the expanded path to unexpanded
|
||||||
# Example: ~/some/path/to/this/file -> /home/foo/path/to/this/file
|
# Example: ~/some/path/to/this/file -> /home/foo/path/to/this/file
|
||||||
@ -729,7 +729,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
"~",
|
"~",
|
||||||
Path(Path(self.test_file).as_posix()).as_posix(),
|
Path(Path(self.test_file).as_posix()).as_posix(),
|
||||||
)
|
)
|
||||||
result = gamelauncher.setup_pfx(unexpanded_path)
|
result = ulwgl_run.setup_pfx(unexpanded_path)
|
||||||
|
|
||||||
# Replaces the expanded path to unexpanded
|
# Replaces the expanded path to unexpanded
|
||||||
# Example: ~/some/path/to/this/file -> /home/foo/path/to/this/file
|
# Example: ~/some/path/to/this/file -> /home/foo/path/to/this/file
|
||||||
@ -748,7 +748,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
def test_setup_pfx(self):
|
def test_setup_pfx(self):
|
||||||
"""Test setup_pfx."""
|
"""Test setup_pfx."""
|
||||||
result = None
|
result = None
|
||||||
result = gamelauncher.setup_pfx(self.test_file)
|
result = ulwgl_run.setup_pfx(self.test_file)
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
result,
|
result,
|
||||||
"Expected None when creating symbolic link to WINE prefix and tracked_files file",
|
"Expected None when creating symbolic link to WINE prefix and tracked_files file",
|
||||||
@ -766,19 +766,19 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
|
|
||||||
There's a requirement to create an empty prefix
|
There's a requirement to create an empty prefix
|
||||||
A SystemExit should be raised in this case:
|
A SystemExit should be raised in this case:
|
||||||
./gamelauncher.py
|
./ulwgl_run.py
|
||||||
"""
|
"""
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
gamelauncher.parse_args()
|
ulwgl_run.parse_args()
|
||||||
|
|
||||||
def test_parse_args_config(self):
|
def test_parse_args_config(self):
|
||||||
"""Test parse_args --config."""
|
"""Test parse_args --config."""
|
||||||
with patch.object(
|
with patch.object(
|
||||||
gamelauncher,
|
ulwgl_run,
|
||||||
"parse_args",
|
"parse_args",
|
||||||
return_value=argparse.Namespace(config=self.test_file),
|
return_value=argparse.Namespace(config=self.test_file),
|
||||||
):
|
):
|
||||||
result = gamelauncher.parse_args()
|
result = ulwgl_run.parse_args()
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
result, Namespace, "Expected a Namespace from parse_arg"
|
result, Namespace, "Expected a Namespace from parse_arg"
|
||||||
)
|
)
|
||||||
@ -792,7 +792,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["WINEPREFIX"] = self.test_file
|
os.environ["WINEPREFIX"] = self.test_file
|
||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
os.environ["PROTONPATH"] = "./foo"
|
os.environ["PROTONPATH"] = "./foo"
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
Path(os.environ["PROTONPATH"]).is_dir(),
|
Path(os.environ["PROTONPATH"]).is_dir(),
|
||||||
"Expected PROTONPATH to not be a directory",
|
"Expected PROTONPATH to not be a directory",
|
||||||
@ -806,7 +806,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["WINEPREFIX"] = "./foo"
|
os.environ["WINEPREFIX"] = "./foo"
|
||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
os.environ["PROTONPATH"] = self.test_file
|
os.environ["PROTONPATH"] = self.test_file
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
Path(os.environ["WINEPREFIX"]).is_dir(),
|
Path(os.environ["WINEPREFIX"]).is_dir(),
|
||||||
True,
|
True,
|
||||||
@ -833,7 +833,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["WINEPREFIX"] = unexpanded_path
|
os.environ["WINEPREFIX"] = unexpanded_path
|
||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
os.environ["PROTONPATH"] = unexpanded_path
|
os.environ["PROTONPATH"] = unexpanded_path
|
||||||
result = gamelauncher.check_env(self.env)
|
result = ulwgl_run.check_env(self.env)
|
||||||
self.assertTrue(result is self.env, "Expected the same reference")
|
self.assertTrue(result is self.env, "Expected the same reference")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.env["WINEPREFIX"], unexpanded_path, "Expected WINEPREFIX to be set"
|
self.env["WINEPREFIX"], unexpanded_path, "Expected WINEPREFIX to be set"
|
||||||
@ -851,7 +851,7 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
os.environ["WINEPREFIX"] = self.test_file
|
os.environ["WINEPREFIX"] = self.test_file
|
||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
os.environ["PROTONPATH"] = self.test_file
|
os.environ["PROTONPATH"] = self.test_file
|
||||||
result = gamelauncher.check_env(self.env)
|
result = ulwgl_run.check_env(self.env)
|
||||||
self.assertTrue(result is self.env, "Expected the same reference")
|
self.assertTrue(result is self.env, "Expected the same reference")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.env["WINEPREFIX"], self.test_file, "Expected WINEPREFIX to be set"
|
self.env["WINEPREFIX"], self.test_file, "Expected WINEPREFIX to be set"
|
||||||
@ -868,18 +868,18 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
with self.assertRaisesRegex(ValueError, "PROTONPATH"):
|
with self.assertRaisesRegex(ValueError, "PROTONPATH"):
|
||||||
os.environ["WINEPREFIX"] = self.test_file
|
os.environ["WINEPREFIX"] = self.test_file
|
||||||
os.environ["GAMEID"] = self.test_file
|
os.environ["GAMEID"] = self.test_file
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
|
|
||||||
def test_env_vars_wine(self):
|
def test_env_vars_wine(self):
|
||||||
"""Test check_env when setting only $WINEPREFIX."""
|
"""Test check_env when setting only $WINEPREFIX."""
|
||||||
with self.assertRaisesRegex(ValueError, "GAMEID"):
|
with self.assertRaisesRegex(ValueError, "GAMEID"):
|
||||||
os.environ["WINEPREFIX"] = self.test_file
|
os.environ["WINEPREFIX"] = self.test_file
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
|
|
||||||
def test_env_vars_none(self):
|
def test_env_vars_none(self):
|
||||||
"""Tests check_env when setting no env vars."""
|
"""Tests check_env when setting no env vars."""
|
||||||
with self.assertRaisesRegex(ValueError, "WINEPREFIX"):
|
with self.assertRaisesRegex(ValueError, "WINEPREFIX"):
|
||||||
gamelauncher.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
Loading…
x
Reference in New Issue
Block a user