Skip to content

Commit

Permalink
tests: add a test with bundled shell script
Browse files Browse the repository at this point in the history
Add a test to ensure that we preserve the executable bit on
collected shell script (a data file with executable bit set).
  • Loading branch information
rokm committed Sep 22, 2023
1 parent 91a8fe3 commit 59ea410
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/functional/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,29 @@ def some_interactive_debugger_function():
some_interactive_debugger_function()
"""
)


# Test that collection of an executable shell script (essentially a data file with executable bit) preserves its
# executable bit.
@pytest.mark.linux
@pytest.mark.darwin
def test_bundled_shell_script(pyi_builder, tmpdir):
script_file = tmpdir / "test_script.sh"
with open(script_file, "w") as fp:
print('#!/bin/sh', file=fp)
print('echo "Hello world!"', file=fp)
os.chmod(script_file, 0o755)

pyi_builder.test_source(
"""
import os
import subprocess
script = os.path.join(os.path.dirname(__file__), 'test_script.sh')
output = subprocess.check_output(script, text=True)
print(output)
assert output.strip() == "Hello world!"
""",
pyi_args=['--add-data', str(script_file) + os.pathsep + '.']
)

0 comments on commit 59ea410

Please sign in to comment.