diff --git a/src/sinol_make/commands/export/__init__.py b/src/sinol_make/commands/export/__init__.py index 46447ca3..9f564642 100644 --- a/src/sinol_make/commands/export/__init__.py +++ b/src/sinol_make/commands/export/__init__.py @@ -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): """ diff --git a/tests/commands/export/test_integration.py b/tests/commands/export/test_integration.py index f9f94e64..dc020cc6 100644 --- a/tests/commands/export/test_integration.py +++ b/tests/commands/export/test_integration.py @@ -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))