Skip to content

Commit

Permalink
ulwgl_test: update test for non-existent WINEPREFIX
Browse files Browse the repository at this point in the history
- When the user sets a path to WINEPREFIX that doesn't exists, we should always create the directories and set the environment variable on their behalf.

- Related to 39b48b4
  • Loading branch information
R1kaB3rN committed Feb 22, 2024
1 parent 15b78b5 commit 6469e62
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions ulwgl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,19 +1467,34 @@ def test_env_proton_nodir(self):
def test_env_wine_dir(self):
"""Test check_env when $WINEPREFIX is not a directory.
An error should not be raised if a WINEPREFIX is set but the path has not been created.
When the user specifies a WINEPREFIX that doesn't exist, make the dirs on their behalf and set it
An error should not be raised in the process
"""
# Set a path does not exist
os.environ["WINEPREFIX"] = "./foo"
os.environ["GAMEID"] = self.test_file
os.environ["PROTONPATH"] = self.test_file

self.assertFalse(
Path(os.environ["WINEPREFIX"]).exists(),
"Expected WINEPREFIX to not exist before check_env",
)

ulwgl_run.check_env(self.env)

# After this, the WINEPREFIX and new dirs should be created for the user
self.assertTrue(
Path(self.env["WINEPREFIX"]).exists(),
"Expected WINEPREFIX to exist after check_env",
)
self.assertEqual(
Path(os.environ["WINEPREFIX"]).is_dir(),
True,
"Expected WINEPREFIX to be created if not already exist",
self.env["WINEPREFIX"],
os.environ["WINEPREFIX"],
"Expected the WINEPREFIX to be set",
)
if Path(os.environ["WINEPREFIX"]).is_dir():
rmtree(os.environ["WINEPREFIX"])

if Path(self.env["WINEPREFIX"]).is_dir():
Path(self.env["WINEPREFIX"]).rmdir()

def test_env_vars_paths(self):
"""Test check_env when setting unexpanded paths for $WINEPREFIX and $PROTONPATH."""
Expand Down

0 comments on commit 6469e62

Please sign in to comment.