From 64008717b8c88cd264dce135a1d4ec29df2be5c3 Mon Sep 17 00:00:00 2001 From: MasloMaslane Date: Wed, 18 Oct 2023 09:39:50 +0200 Subject: [PATCH] Add tests --- tests/commands/run/test_integration.py | 9 ++++++--- tests/packages/large_output/config.yml | 13 +++++++++++++ tests/packages/large_output/in/lou0.in | 1 + tests/packages/large_output/out/.gitkeep | 0 tests/packages/large_output/prog/lou.cpp | 11 +++++++++++ tests/packages/large_output/prog/lou1.cpp | 11 +++++++++++ tests/util.py | 11 ++++++++++- 7 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 tests/packages/large_output/config.yml create mode 100644 tests/packages/large_output/in/lou0.in create mode 100644 tests/packages/large_output/out/.gitkeep create mode 100644 tests/packages/large_output/prog/lou.cpp create mode 100644 tests/packages/large_output/prog/lou1.cpp diff --git a/tests/commands/run/test_integration.py b/tests/commands/run/test_integration.py index f20e66a0..795e1b73 100644 --- a/tests/commands/run/test_integration.py +++ b/tests/commands/run/test_integration.py @@ -14,7 +14,8 @@ @pytest.mark.parametrize("create_package", [get_simple_package_path(), get_verify_status_package_path(), get_checker_package_path(), get_library_package_path(), get_library_string_args_package_path(), get_limits_package_path(), - get_override_limits_package_path(), get_icpc_package_path()], + get_override_limits_package_path(), get_icpc_package_path(), + get_large_output_package_path()], indirect=True) def test_simple(create_package, time_tool): """ @@ -70,7 +71,8 @@ def test_wrong_solution(create_package, time_tool): @pytest.mark.parametrize("create_package", [get_simple_package_path(), get_verify_status_package_path(), get_checker_package_path(), get_library_package_path(), get_library_string_args_package_path(), get_limits_package_path(), - get_override_limits_package_path(), get_icpc_package_path()], + get_override_limits_package_path(), get_icpc_package_path(), + get_large_output_package_path()], indirect=True) def test_no_expected_scores(capsys, create_package, time_tool): """ @@ -106,7 +108,8 @@ def test_no_expected_scores(capsys, create_package, time_tool): @pytest.mark.parametrize("create_package", [get_simple_package_path(), get_verify_status_package_path(), get_checker_package_path(), get_library_package_path(), get_library_string_args_package_path(), get_limits_package_path(), - get_override_limits_package_path(), get_icpc_package_path()], + get_override_limits_package_path(), get_icpc_package_path(), + get_large_output_package_path()], indirect=True) def test_apply_suggestions(create_package, time_tool): """ diff --git a/tests/packages/large_output/config.yml b/tests/packages/large_output/config.yml new file mode 100644 index 00000000..5b3bc6fc --- /dev/null +++ b/tests/packages/large_output/config.yml @@ -0,0 +1,13 @@ +title: Package with large outputs +sinol_task_id: lou +memory_limit: 16000 +time_limit: 2000 +sinol_expected_scores: + lou.cpp: + expected: + 0: {points: 0, status: OK} + points: 0 + lou1.cpp: + expected: + 0: {points: 0, status: WA} + points: 0 diff --git a/tests/packages/large_output/in/lou0.in b/tests/packages/large_output/in/lou0.in new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests/packages/large_output/in/lou0.in @@ -0,0 +1 @@ +1 diff --git a/tests/packages/large_output/out/.gitkeep b/tests/packages/large_output/out/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/packages/large_output/prog/lou.cpp b/tests/packages/large_output/prog/lou.cpp new file mode 100644 index 00000000..5210d78b --- /dev/null +++ b/tests/packages/large_output/prog/lou.cpp @@ -0,0 +1,11 @@ +#include + +using namespace std; + +int main() { + int bytes_to_write = (1 << 16) + 1; + for (int i = 0; i < bytes_to_write; i++) { + cout << "x"; + } + return 0; +} diff --git a/tests/packages/large_output/prog/lou1.cpp b/tests/packages/large_output/prog/lou1.cpp new file mode 100644 index 00000000..fa18643a --- /dev/null +++ b/tests/packages/large_output/prog/lou1.cpp @@ -0,0 +1,11 @@ +#include + +using namespace std; + +int main() { + int bytes_to_write = (1 << 20); + for (int i = 0; i < bytes_to_write; i++) { + cout << "x"; + } + return 0; +} diff --git a/tests/util.py b/tests/util.py index 3034c9dd..5b7d3fad 100644 --- a/tests/util.py +++ b/tests/util.py @@ -122,11 +122,20 @@ def get_icpc_package_path(): return os.path.join(os.path.dirname(__file__), "packages", "icpc") +def get_large_output_package_path(): + """ + Get path to package with large output (/tests/packages/large_output) + """ + return os.path.join(os.path.dirname(__file__), "packages", "large_output") + def create_ins(package_path, task_id): """ Create .in files for package. """ - ingen = package_util.get_files_matching_pattern(task_id, f'{task_id}ingen.*')[0] + all_ingens = package_util.get_files_matching_pattern(task_id, f'{task_id}ingen.*') + if len(all_ingens) == 0: + return + ingen = all_ingens[0] ingen_executable = paths.get_executables_path("ingen.e") os.makedirs(paths.get_executables_path(), exist_ok=True) assert compile.compile(ingen, ingen_executable)