Skip to content

Commit

Permalink
Add and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff128 committed Jul 1, 2024
1 parent 1a3d77f commit 3b3d536
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Binary file added sio/compilers/test/sources/simple.zip
Binary file not shown.
39 changes: 39 additions & 0 deletions sio/compilers/test/test_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion sio/executors/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 3b3d536

Please sign in to comment.