From ceb8f25e1c74e872064608d74c74235812c2b32f Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Mon, 19 Feb 2024 18:59:24 +0100 Subject: [PATCH] Create ocen archive only for OI packages (#191) * Create ocen only for OI * Add test --- src/sinol_make/commands/export/__init__.py | 7 ++++--- tests/commands/export/test_integration.py | 17 +++++++++++++++++ tests/packages/icpc/config.yml | 4 ++++ tests/packages/icpc/prog/acmingen.cpp | 5 ++++- tests/packages/ocen/config.yml | 1 + 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/sinol_make/commands/export/__init__.py b/src/sinol_make/commands/export/__init__.py index 2ff67203..46097ff8 100644 --- a/src/sinol_make/commands/export/__init__.py +++ b/src/sinol_make/commands/export/__init__.py @@ -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 @@ -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): """ diff --git a/tests/commands/export/test_integration.py b/tests/commands/export/test_integration.py index 9405a902..a7a73647 100644 --- a/tests/commands/export/test_integration.py +++ b/tests/commands/export/test_integration.py @@ -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")) diff --git a/tests/packages/icpc/config.yml b/tests/packages/icpc/config.yml index be144ecb..3e8334af 100644 --- a/tests/packages/icpc/config.yml +++ b/tests/packages/icpc/config.yml @@ -6,6 +6,7 @@ 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} @@ -13,6 +14,7 @@ sinol_expected_scores: 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} @@ -20,6 +22,7 @@ sinol_expected_scores: 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} @@ -27,6 +30,7 @@ sinol_expected_scores: 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} diff --git a/tests/packages/icpc/prog/acmingen.cpp b/tests/packages/icpc/prog/acmingen.cpp index bdee7ab2..15a994fa 100644 --- a/tests/packages/icpc/prog/acmingen.cpp +++ b/tests/packages/icpc/prog/acmingen.cpp @@ -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"); diff --git a/tests/packages/ocen/config.yml b/tests/packages/ocen/config.yml index c714bd75..a9ceaab8 100644 --- a/tests/packages/ocen/config.yml +++ b/tests/packages/ocen/config.yml @@ -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