Skip to content

Commit

Permalink
Create ocen archive only for OI packages (#191)
Browse files Browse the repository at this point in the history
* Create ocen only for OI

* Add test
  • Loading branch information
MasloMaslane authored Feb 19, 2024
1 parent 31bb4b6 commit ceb8f25
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/sinol_make/commands/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import argparse
import yaml

from sinol_make import util
from sinol_make import util, contest_types
from sinol_make.commands.ingen.ingen_util import get_ingen, compile_ingen, run_ingen, ingen_exists
from sinol_make.helpers import package_util, parsers, paths
from sinol_make.interfaces.BaseCommand import BaseCommand
Expand Down Expand Up @@ -165,8 +165,9 @@ def copy_package_required_files(self, target_dir: str):
shutil.copy(test[1], os.path.join(cache_test_dir, test[0], os.path.basename(test[1])))

self.generate_output_files()
print('Generating ocen archive...')
self.create_ocen(target_dir)
if isinstance(contest_types.get_contest_type(), contest_types.OIContest):
print('Generating ocen archive...')
self.create_ocen(target_dir)

def clear_files(self, target_dir: str):
"""
Expand Down
17 changes: 17 additions & 0 deletions tests/commands/export/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,20 @@ def test_ocen_archive(create_package):
for ext in ["in", "out"]:
tests = [os.path.basename(f) for f in glob.glob(os.path.join(ocen_dir, task_id, ext, f'*.{ext}'))]
assert set(tests) == set([f'{test}.{ext}' for test in ocen_tests])


@pytest.mark.parametrize("create_package", [util.get_icpc_package_path()], indirect=True)
def test_no_ocen(create_package):
"""
Test if ocen archive is not created for contests other than OI.
"""
parser = configure_parsers()
args = parser.parse_args(["export", "--no-statement"])
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)
assert not os.path.exists(os.path.join(tmpdir, task_id, "attachments", f"{task_id}ocen.zip"))
4 changes: 4 additions & 0 deletions tests/packages/icpc/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ time_limit: 1000
sinol_expected_scores:
acm.cpp:
expected:
0: {points: 1, status: OK}
1: {points: 1, status: OK}
2: {points: 1, status: OK}
3: {points: 1, status: OK}
4: {points: 1, status: OK}
points: 1
acm1.cpp:
expected:
0: {points: 1, status: OK}
1: {points: 1, status: OK}
2: {points: 1, status: OK}
3: {points: 1, status: OK}
4: {points: 0, status: WA}
points: 0
acm2.cpp:
expected:
0: {points: 0, status: WA}
1: {points: 1, status: OK}
2: {points: 0, status: WA}
3: {points: 0, status: WA}
4: {points: 0, status: TL}
points: 0
acm3.cpp:
expected:
0: {points: 0, status: WA}
1: {points: 1, status: OK}
2: {points: 0, status: WA}
3: {points: 0, status: WA}
Expand Down
5 changes: 4 additions & 1 deletion tests/packages/icpc/prog/acmingen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
using namespace std;

int main() {
ofstream f("acm1a.in");
ofstream f("acm0.in");
f << "0 0\n";
f.close();
f.open("acm1a.in");
f << "1 3\n";
f.close();
f.open("acm2a.in");
Expand Down
1 change: 1 addition & 0 deletions tests/packages/ocen/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
title: Package for testing ocen archive creation
sinol_task_id: ocen
sinol_contest_type: oi
time_limit: 1000
memory_limit: 10240

0 comments on commit ceb8f25

Please sign in to comment.