Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Apr 20, 2024
1 parent e69a6ef commit 18af535
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 116 deletions.
109 changes: 2 additions & 107 deletions umu/umu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pathlib import Path
from shutil import rmtree, copytree, copy
from pwd import getpwuid
from umu_consts import MODE


class TestGameLauncher(unittest.TestCase):
Expand Down Expand Up @@ -164,106 +163,6 @@ def tearDown(self):
if self.test_local_share.exists():
rmtree(self.test_local_share.as_posix())

def test_copy(self):
"""Test _copy when copying a subset of core files from a system path."""
# Make files read-only
self.test_user_share.joinpath("reaper").chmod(0o0444)
self.test_user_share.joinpath("umu_run.py").chmod(0o0444)
self.test_user_share.joinpath("umu_consts.py").chmod(0o0444)
# Make umu-launcher files read-only
Path(self.test_user_share, "umu-launcher", "compatibilitytool.vdf").chmod(
0o0444
)
Path(self.test_user_share, "umu-launcher", "toolmanifest.vdf").chmod(0o0444)
# Verify read-only before copying to ~/.local/share/umu
self.assertTrue(
self.test_user_share.joinpath("reaper").stat().st_mode == 33060,
"Expected reaper to be read only",
)
self.assertTrue(
self.test_user_share.joinpath("umu_run.py").stat().st_mode == 33060,
"Expected umu_run to be read only",
)
self.assertTrue(
self.test_user_share.joinpath("umu_consts.py").stat().st_mode == 33060,
"Expected umu_consts to be read only",
)
self.assertTrue(
self.test_user_share.joinpath("umu-launcher", "compatibilitytool.vdf")
.stat()
.st_mode
== 33060,
"Expected compat vdf to be read only",
)
self.assertTrue(
self.test_user_share.joinpath("umu-launcher", "toolmanifest.vdf")
.stat()
.st_mode
== 33060,
"Expected manifest vdf to be read only",
)
# Copy from source dir
umu_util._copy(
self.test_user_share.joinpath("reaper"),
self.test_local_share.joinpath("reaper"),
MODE.USER_RWX,
)
umu_util._copy(
self.test_user_share.joinpath("umu_run.py"),
self.test_local_share.joinpath("umu_run.py"),
MODE.USER_RWX,
)
umu_util._copy(
self.test_user_share.joinpath("umu_consts.py"),
self.test_local_share.joinpath("umu_consts.py"),
)
umu_util._copytree(
self.test_user_share.joinpath("umu-launcher"),
self.test_local_share.joinpath("umu-launcher"),
)
# Test reaper for user rwx
# In particular, it's important umu_run and reaper are executable
# otherwise, the launcher will not work
self.assertTrue(
os.access(self.test_local_share.joinpath("reaper"), os.X_OK),
"Expected execute perm for reaper",
)
self.assertTrue(
os.access(self.test_local_share.joinpath("reaper"), os.W_OK),
"Expected write perm for reaper",
)
# Test umu_run.py for user rwx
self.assertTrue(
os.access(self.test_local_share.joinpath("umu_run.py"), os.X_OK),
"Expected execute perm for umu_run",
)
self.assertTrue(
os.access(self.test_local_share.joinpath("umu_run.py"), os.W_OK),
"Expected write perm for umu_run",
)
# Test launcher files for user rw
# Just test one of them since the default is rw and if one of them
# fails then that signals the rest will too
self.assertTrue(
os.access(self.test_local_share.joinpath("umu_consts.py"), os.W_OK),
"Expected write perm for launcher file",
)
# Test umu-launcher
self.assertTrue(
os.access(
self.test_local_share.joinpath("umu-launcher", "compatibilitytool.vdf"),
os.W_OK,
),
"Expected write perm for launcher file",
)
self.assertTrue(
os.access(
self.test_local_share.joinpath("umu-launcher", "toolmanifest.vdf"),
os.W_OK,
),
"Expected write perm for launcher file",
)

def test_ge_proton(self):
"""Test check_env when the code name GE-Proton is set for PROTONPATH.
Expand Down Expand Up @@ -357,7 +256,6 @@ def test_update_umu_empty(self):
result = umu_util._update_umu(
self.test_user_share,
self.test_local_share,
self.test_compat,
json_root,
json_local,
)
Expand Down Expand Up @@ -543,7 +441,6 @@ def test_update_umu(self):
result = umu_util._update_umu(
self.test_user_share,
self.test_local_share,
self.test_compat,
json_root,
json_local,
)
Expand Down Expand Up @@ -662,7 +559,7 @@ def test_install_umu(self):
return_value=None,
):
result = umu_util._install_umu(
self.test_user_share, self.test_local_share, self.test_compat, json
self.test_user_share, self.test_local_share, json
)
copytree(
Path(self.test_user_share, "sniper_platform_0.20240125.75305"),
Expand Down Expand Up @@ -1490,9 +1387,7 @@ def test_build_command(self):
"setup_runtime",
return_value=None,
):
umu_util._install_umu(
self.test_user_share, self.test_local_share, self.test_compat, json
)
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Path(self.test_user_share, "sniper_platform_0.20240125.75305"),
Path(self.test_local_share, "sniper_platform_0.20240125.75305"),
Expand Down
12 changes: 3 additions & 9 deletions umu/umu_test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ def test_build_command_entry(self):
"setup_runtime",
return_value=None,
):
umu_util._install_umu(
self.test_user_share, self.test_local_share, self.test_compat, json
)
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Path(self.test_user_share, "sniper_platform_0.20240125.75305"),
Path(self.test_local_share, "sniper_platform_0.20240125.75305"),
Expand Down Expand Up @@ -287,9 +285,7 @@ def test_build_command_proton(self):
"setup_runtime",
return_value=None,
):
umu_util._install_umu(
self.test_user_share, self.test_local_share, self.test_compat, json
)
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Path(self.test_user_share, "sniper_platform_0.20240125.75305"),
Path(self.test_local_share, "sniper_platform_0.20240125.75305"),
Expand Down Expand Up @@ -360,9 +356,7 @@ def test_build_command_toml(self):
"setup_runtime",
return_value=None,
):
umu_util._install_umu(
self.test_user_share, self.test_local_share, self.test_compat, json
)
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Path(self.test_user_share, "sniper_platform_0.20240125.75305"),
Path(self.test_local_share, "sniper_platform_0.20240125.75305"),
Expand Down

0 comments on commit 18af535

Please sign in to comment.