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

Fix handwritten tests in exported package #169

Merged
merged 2 commits into from
Jan 3, 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
6 changes: 3 additions & 3 deletions src/sinol_make/commands/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ def copy_package_required_files(self, target_dir: str):
for ext in ['in', 'out']:
for test in glob.glob(os.path.join(os.getcwd(), ext, f'{self.task_id}*.{ext}')):
if package_util.extract_test_id(test, self.task_id) not in generated_tests:
tests_to_copy.append(test)
tests_to_copy.append((ext, test))

if len(tests_to_copy) > 0:
print(util.warning(f'Found {len(tests_to_copy)} tests that are not generated by ingen.'))
for test in tests_to_copy:
print(util.warning(f'Coping {os.path.basename(test)}...'))
shutil.copy(test, os.path.join(target_dir, os.path.splitext(os.path.basename(test))[1]))
print(util.warning(f'Coping {os.path.basename(test[1])}...'))
shutil.copy(test[1], os.path.join(target_dir, test[0], os.path.basename(test[1])))

def clear_files(self, target_dir: str):
"""
Expand Down
20 changes: 20 additions & 0 deletions tests/commands/export/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,23 @@ def test_correct_permissions(create_package, capsys):
assert os.path.exists(shell_ingen)
st = os.stat(shell_ingen)
assert st.st_mode & stat.S_IEXEC


@pytest.mark.parametrize("create_package", [util.get_handwritten_package_path()], indirect=True)
def test_handwritten_tests(create_package):
"""
Test if handwritten tests are correctly copied.
"""
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:
sinol_util.extract_tar(tar, tmpdir)

extracted = os.path.join(tmpdir, task_id)
for file in ["in/hwr0.in", "in/hwr0a.in", "out/hwr0.out", "out/hwr0a.out"]:
assert os.path.exists(os.path.join(extracted, file))
Loading