diff --git a/sio/compilers/test/sources/simple.zip b/sio/compilers/test/sources/simple.zip new file mode 100644 index 0000000..d6ccbe8 Binary files /dev/null and b/sio/compilers/test/sources/simple.zip differ 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())