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

sinol-make export should add +x to xyzingen.sh #142

Merged
merged 2 commits into from
Oct 9, 2023
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
5 changes: 5 additions & 0 deletions src/sinol_make/commands/export/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import glob
import stat
import shutil
import tarfile
import argparse
Expand Down Expand Up @@ -62,6 +63,10 @@ def copy_package_required_files(self, target_dir: str):
shutil.copytree(file_path, os.path.join(target_dir, file))
else:
shutil.copy(file_path, target_dir)
shell_ingen = os.path.join(target_dir, 'prog', f'{self.task_id}ingen.sh')
if os.path.exists(shell_ingen):
st = os.stat(shell_ingen)
os.chmod(shell_ingen, st.st_mode | stat.S_IEXEC)

print('Copying example tests...')
for ext in ['in', 'out']:
Expand Down
26 changes: 26 additions & 0 deletions tests/commands/export/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import yaml
import stat
import glob
import pytest
import tarfile
Expand Down Expand Up @@ -80,3 +81,28 @@ def test_doc_cleared(create_package):
assert os.path.exists(extracted)
for pattern in ['doc/*~', 'doc/*.aux', 'doc/*.log', 'doc/*.dvi', 'doc/*.err', 'doc/*.inf']:
assert glob.glob(os.path.join(extracted, pattern)) == []


@pytest.mark.parametrize("create_package", [util.get_shell_ingen_pack_path()], indirect=True)
def test_correct_permissions(create_package, capsys):
"""
Checks if shell ingen has correct permissions.
"""
shell_ingen = os.path.join(os.getcwd(), 'prog', f'{package_util.get_task_id()}ingen.sh')
st = os.stat(shell_ingen)
os.chmod(shell_ingen, st.st_mode & ~stat.S_IEXEC)

parser = configure_parsers()
args = parser.parse_args(["export"])
command = Command()
command.run(args)
task_id = package_util.get_task_id()

with tempfile.TemporaryDirectory() as tmpdir:
with tarfile.open(f'{task_id}.tgz', "r") as tar:
tar.extractall(tmpdir)

shell_ingen = os.path.join(tmpdir, task_id, 'prog', f'{task_id}ingen.sh')
assert os.path.exists(shell_ingen)
st = os.stat(shell_ingen)
assert st.st_mode & stat.S_IEXEC