Skip to content

Commit

Permalink
Merge pull request #451 from dodona-edu/fix/tutor-bugs
Browse files Browse the repository at this point in the history
Only provide debug info for supported languages
  • Loading branch information
niknetniko authored Oct 25, 2023
2 parents b73e212 + 3b309f1 commit f6084c5
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions tested/judge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,43 +331,46 @@ def _process_results(
compilation_results=compilation_results,
)

# TODO: this is currently very Python-specific
# See if we need a callback to the language modules in the future.
# TODO: we could probably re-use the "readable_input" function here,
# since it only differs a bit.
meta_statements = []
meta_stdin = None
for case in planned.context.testcases:
if case.is_main_testcase():
assert isinstance(case.input, MainInput)
if isinstance(case.input.stdin, TextData):
meta_stdin = case.input.stdin.get_data_as_string(
bundle.config.resources
)
elif isinstance(case.input, Statement):
stmt = generate_statement(bundle, case.input)
meta_statements.append(stmt)
elif isinstance(case.input, LanguageLiterals):
stmt = case.input.get_for(bundle.config.programming_language)
meta_statements.append(stmt)
if bundle.language.supports_debug_information():
# TODO: this is currently very Python-specific
# See if we need a callback to the language modules in the future.
# TODO: we could probably re-use the "readable_input" function here,
# since it only differs a bit.
meta_statements = []
meta_stdin = None
for case in planned.context.testcases:
if case.is_main_testcase():
assert isinstance(case.input, MainInput)
if isinstance(case.input.stdin, TextData):
meta_stdin = case.input.stdin.get_data_as_string(
bundle.config.resources
)
elif isinstance(case.input, Statement):
stmt = generate_statement(bundle, case.input)
meta_statements.append(stmt)
elif isinstance(case.input, LanguageLiterals):
stmt = case.input.get_for(bundle.config.programming_language)
meta_statements.append(stmt)
else:
raise AssertionError(f"Found unknown case input type: {case.input}")

if meta_statements:
meta_statements = "\n".join(meta_statements)
else:
raise AssertionError(f"Found unknown case input type: {case.input}")

if meta_statements:
meta_statements = "\n".join(meta_statements)
# Don't add empty statements
meta_statements = None

collector.add(
CloseContext(
data=Metadata(
statements=meta_statements,
stdin=meta_stdin,
)
),
planned.context_index,
)
else:
# Don't add empty statements
meta_statements = None

collector.add(
CloseContext(
data=Metadata(
statements=meta_statements,
stdin=meta_stdin,
)
),
planned.context_index,
)
collector.add(CloseContext(), planned.context_index)
if continue_ in (Status.TIME_LIMIT_EXCEEDED, Status.MEMORY_LIMIT_EXCEEDED):
return continue_, currently_open_tab

Expand Down

0 comments on commit f6084c5

Please sign in to comment.