Skip to content

Commit

Permalink
Add comments for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrv committed Jul 23, 2024
1 parent 039f62f commit 982faaf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pyiron_snippets/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ class ExecutableResolver(AbstractResolver):
and have the executable bit set. :meth:`.search` yields tuples of version strings and full paths to the executable
instead of plain strings.
Except on windows results are filtered to make sure all returned scripts have the executable bit set.
When the bit is not set, a warning is printed.
>>> exe = ExecutableResolver(..., "lammps")
>>> exe.list() # doctest: +SKIP
[
Expand Down Expand Up @@ -253,6 +256,7 @@ def _search(self, name):

def cond(path):
isfile = os.path.isfile(path)
# HINT: this is always True on windows
isexec = os.access(
path, os.X_OK, effective_ids=os.access in os.supports_effective_ids
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def test_executable(self):
for suffix in (None, "sh", "bat"):
with self.subTest(suffix=suffix):
res = ExecutableResolver([self.res1], code="code1", module="module1", suffix=suffix)
# Windows always reports the exec bit as set, so skip those tests there
if os.name != "nt":
with self.assertLogs(logger, level="WARNING"):
res.list()
# no exec bits are present on windows it seems
self.assertNotIn("versionnonexec", res.available_versions,
"ExecutableResolver must not list scripts that are not executable.")
self.assertNotIn("wrong_format", res.available_versions,
Expand Down

0 comments on commit 982faaf

Please sign in to comment.