Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pressure Vessel and Runtime #97

Merged
merged 8 commits into from
Apr 25, 2024
Merged
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: 3 additions & 1 deletion umu/umu_dl_util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from sys import version
from tarfile import open as tar_open, TarInfo
from pathlib import Path
from os import environ
Expand Down Expand Up @@ -192,7 +193,8 @@ def _extract_dir(file: Path, steam_compat: Path) -> None:
log.debug("Using filter for archive")
tar.extraction_filter = tar_filter
else:
log.debug("Using no filter for archive")
log.warning("Python: %s", version)
log.warning("Using no data filter for archive")
log.warning("Archive will be extracted insecurely")

log.console(f"Extracting {file} -> {steam_compat} ...")
Expand Down
73 changes: 55 additions & 18 deletions umu/umu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,53 @@ def tearDown(self):
if self.test_local_share.exists():
rmtree(self.test_local_share.as_posix())

def test_move(self):
"""Test _move when copying a directory or a file.

This function simply wraps shutil.move but deletes the dest directory
before moving the source directory. While not strictly necesssary,
doing this maintains the integrity of the runtime platform's directory
tree defined in the mtree.txt.gz file
"""
test_dir = self.test_user_share.joinpath("foo")
test_file = self.test_user_share.joinpath("bar")
test_dir.mkdir()
test_file.touch()
self.test_user_share.joinpath("qux").symlink_to(test_file)

# Directory
umu_util._move(test_dir, self.test_user_share, self.test_local_share)
self.assertFalse(
self.test_user_share.joinpath("foo").exists(), "foo did not move from src"
)
self.assertTrue(
self.test_local_share.joinpath("foo").exists(), "foo did not move to dst"
)

# File
umu_util._move(test_file, self.test_user_share, self.test_local_share)
self.assertFalse(
self.test_user_share.joinpath("bar").exists(), "bar did not move from src"
)
self.assertTrue(
self.test_local_share.joinpath("bar").exists(), "bar did not move to dst"
)

# Link
umu_util._move(
self.test_user_share.joinpath("qux"),
self.test_user_share,
self.test_local_share,
)
self.assertFalse(
self.test_user_share.joinpath("qux").is_symlink(),
"qux did not move from src",
)
self.assertTrue(
self.test_local_share.joinpath("qux").is_symlink(),
"qux did not move to dst",
)

def test_ge_proton(self):
"""Test check_env when the code name GE-Proton is set for PROTONPATH.

Expand Down Expand Up @@ -240,10 +287,8 @@ def test_update_umu_empty(self):
)

# Update
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
result = umu_util._update_umu(
self.test_local_share,
Expand All @@ -265,7 +310,6 @@ def test_update_umu_empty(self):
Path(self.test_user_share, "umu"),
Path(self.test_local_share, "umu"),
)
# When the runtime updates, pressure vessel needs to be updated
copytree(
Path(self.test_user_share, "pressure-vessel"),
Path(self.test_local_share, "pressure-vessel"),
Expand Down Expand Up @@ -391,10 +435,8 @@ def test_update_umu(self):
self.test_local_share.joinpath("pressure-vessel", "bar").touch()

# Update
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
result = umu_util._update_umu(
self.test_local_share,
Expand All @@ -416,7 +458,6 @@ def test_update_umu(self):
Path(self.test_user_share, "umu"),
Path(self.test_local_share, "umu"),
)
# When the runtime updates, pressure vessel needs to be updated
copytree(
Path(self.test_user_share, "pressure-vessel"),
Path(self.test_local_share, "pressure-vessel"),
Expand Down Expand Up @@ -494,10 +535,8 @@ def test_install_umu(self):
# Mock setting up the runtime
# In the real usage, we callout to acquire the archive and
# extract to .local/share/umu
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
result = umu_util._install_umu(
self.test_user_share, self.test_local_share, json
Expand Down Expand Up @@ -1307,10 +1346,8 @@ def test_build_command(self):
os.environ[key] = val

# Mock setting up the runtime
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Expand Down
18 changes: 6 additions & 12 deletions umu/umu_test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ def test_build_command_entry(self):

# Mock setting up the runtime
# Don't copy _v2-entry-point
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Expand Down Expand Up @@ -282,10 +280,8 @@ def test_build_command_proton(self):
umu_plugins.enable_steam_game_drive(self.env)

# Mock setting up the runtime
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Expand Down Expand Up @@ -355,10 +351,8 @@ def test_build_command_toml(self):
umu_plugins.enable_steam_game_drive(self.env)

# Mock setting up the runtime
with patch.object(
umu_util,
"setup_runtime",
return_value=None,
with (
patch.object(umu_util, "setup_runtime", return_value=None),
):
umu_util._install_umu(self.test_user_share, self.test_local_share, json)
copytree(
Expand Down
Loading