From 3b3d536f54170cdd9fb55cc11ea933790051b72c Mon Sep 17 00:00:00 2001 From: tkwiatkowski Date: Mon, 1 Jul 2024 19:48:02 +0200 Subject: [PATCH] Add and fix tests --- sio/compilers/test/sources/simple.zip | Bin 0 -> 249 bytes sio/compilers/test/test_compilers.py | 39 ++++++++++++++++++++++++++ sio/executors/common.py | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sio/compilers/test/sources/simple.zip diff --git a/sio/compilers/test/sources/simple.zip b/sio/compilers/test/sources/simple.zip new file mode 100644 index 0000000000000000000000000000000000000000..d6ccbe8d1f854a70df1871b2e14becf252971c9d GIT binary patch literal 249 zcmWIWW@Zs#W?JZ34L8n4c&`p&!1iyQgOv7^kHDQbVuElD-0=Sj5EC#e9_Uc756fK$sp-1nj<14 zDp#r(;K4MBTXa(66QNcSg`Hd)+*fYdc{&~z^zaQVxb%dHA;6oF$(|XPQ&fPC0Re@E zEsY==<}fY>1rV2kkwJoiK_XG=jP5N)hNSYgd#8c4m`yi`4)A7WgQ#I-hypS?K^z7E D{DeeD literal 0 HcmV?d00001 diff --git a/sio/compilers/test/test_compilers.py b/sio/compilers/test/test_compilers.py index 5c16ecd..4794365 100644 --- a/sio/compilers/test/test_compilers.py +++ b/sio/compilers/test/test_compilers.py @@ -182,6 +182,45 @@ def test_output_compilation_and_running(source): eq_(outfile.read(), sourcefile.read()) +@pytest.mark.parametrize("source", [('/simple.zip')]) +def test_output_archive_compilation_and_running(source): + with TemporaryCwd(): + upload_files() + result_env = run( + { + 'source_file': source, + 'compiler': 'output-only', + } + ) + eq_(result_env['result_code'], 'OK') + eq_(result_env['exec_info'], {'mode': 'output-only'}) + + ft.download(result_env, 'out_file', tempcwd('out.txt')) + ft.download({'source_file': source}, 'source_file', tempcwd('source.txt')) + with open(tempcwd('out.txt'), 'r') as outfile: + with open(tempcwd('source.txt'), 'r') as sourcefile: + eq_(outfile.read(), sourcefile.read()) + + post_run_env = run_from_executors( + { + 'exec_info': result_env['exec_info'], + 'exe_file': result_env['out_file'], + 'check_output': True, + 'hint_file': source, + 'name': '0', + 'problem_short_name': 'abc', + }, + executor=None, + ) + eq_(post_run_env['result_code'], 'OK') + + ft.download(post_run_env, 'out_file', tempcwd('out.txt')) + ft.download({'source_file': source}, 'source_file', tempcwd('source.txt')) + with open(tempcwd('out.txt'), 'r') as outfile: + with open(tempcwd('source.txt'), 'r') as sourcefile: + eq_(outfile.read(), sourcefile.read()) + + def _make_compilation_with_additional_library_cases(): compilers = ['system-'] if ENABLE_SANDBOXED_COMPILERS: diff --git a/sio/executors/common.py b/sio/executors/common.py index 28c102c..438b545 100644 --- a/sio/executors/common.py +++ b/sio/executors/common.py @@ -118,9 +118,9 @@ def _run(environ, executor, use_sandboxes): def _fake_run_as_exe_is_output_file(environ): try: ft.download(environ, 'exe_file', tempcwd('outs_archive')) + archive = Archive.get(tempcwd('outs_archive')) problem_short_name = environ['problem_short_name'] test_name = f'{problem_short_name}{environ["name"]}.out' - archive = Archive.get(tempcwd('outs_archive')) logger.info('Archive with outs provided') if test_name in archive.filenames(): archive.extract(test_name, to_path=tempcwd())