Skip to content

Commit 730896a

Browse files
authored
Remove '.e' files from prog directory (#301)
1 parent 04377f6 commit 730896a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/sinol_make/commands/export/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ def copy_package_required_files(self, target_dir: str):
162162
st = os.stat(shell_ingen)
163163
os.chmod(shell_ingen, st.st_mode | stat.S_IEXEC)
164164

165+
# Remove '.e' files from prog directory
166+
prog_dir = os.path.join(target_dir, 'prog')
167+
for file in glob.glob(os.path.join(prog_dir, f'{self.task_id}*.e')):
168+
os.remove(file)
169+
165170
print('Copying example tests...')
166171
for ext in ['in', 'out']:
167172
os.mkdir(os.path.join(target_dir, ext))

tests/commands/export/test_integration.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,28 @@ def test_dlazaw_ocen(create_package):
279279

280280
assert not os.path.exists(os.path.join(tmpdir, task_id, "attachments", f"{task_id}ocen.zip"))
281281
assert os.path.join(tmpdir, task_id, "attachments", f"dlazaw.zip")
282+
283+
284+
@pytest.mark.parametrize("create_package", [util.get_simple_package_path()], indirect=True)
285+
def test_e_files_removal(create_package):
286+
"""
287+
Test if .e files are removed from the prog directory in the archive.
288+
"""
289+
package_path = create_package
290+
task_id = package_util.get_task_id()
291+
prog_path = os.path.join(package_path, "prog")
292+
e_file = os.path.join(prog_path, f"{task_id}e.e")
293+
with open(e_file, "w") as f:
294+
f.write("This is a test e file.")
295+
296+
parser = configure_parsers()
297+
args = parser.parse_args(["export", "--no-statement"])
298+
command = Command()
299+
command.run(args)
300+
301+
with tempfile.TemporaryDirectory() as tmpdir:
302+
with tarfile.open(f'{task_id}.tgz', "r") as tar:
303+
sinol_util.extract_tar(tar, tmpdir)
304+
305+
extracted = os.path.join(tmpdir, task_id)
306+
assert not os.path.exists(os.path.join(extracted, "prog", f"{task_id}e.e"))

0 commit comments

Comments
 (0)