Skip to content

Commit

Permalink
Improve messages
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Oct 6, 2023
1 parent 432153e commit f25903c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
7 changes: 2 additions & 5 deletions tested/internationalization/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ en:
source-code: "Invalid source code"
initialization: "Error while initializing the code:"
evaluation:
early-exit: "The evaluation has stopped early."
time-limit: "Time limit exceeded"
memory-limit: "Memory limit exceeded"
missing:
context: "Context not executed"
output: "Missing output"
test: "Test not executed"
not-executed: "These test(s) were not executed"
missing: "Missing result"
files:
zero: "No files"
one: "File: %{files}"
Expand Down
11 changes: 4 additions & 7 deletions tested/internationalization/nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ nl:
source-code: "Ongeldige broncode"
initialization: "Fout tijdens het initialiseren van de code:"
evaluation:
early-exit: "De beoordeling is vroegtijdig gestopt."
time-limit: "Tijdslimiet overschreden."
memory-limit: "Geheugenlimiet overschreden."
missing:
context: "Context niet uitgevoerd"
output: "Ontbrekende uitvoer"
test: "Test niet uitgevoerd"
time-limit: "Tijdslimiet overschreden"
memory-limit: "Geheugenlimiet overschreden"
not-executed: "Deze test(en) werden niet uitgevoerd"
missing: "Ontbrekend resultaat"
files:
zero: "Geen bestanden"
one: "Bestand: %{files}"
Expand Down
56 changes: 31 additions & 25 deletions tested/judge/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _evaluate_channel(
unexpected_status: Status = Status.WRONG,
timeout: bool = False,
memory: bool = False,
) -> bool | None:
) -> bool:
"""
Evaluate the output on a given channel. This function will output the
appropriate messages to start and end a new test in Dodona.
Expand All @@ -104,7 +104,7 @@ def _evaluate_channel(
:param bundle: The configuration bundle.
:param context_directory: The directory in which the execution took place.
:return: True if successful, otherwise False.
:return: True indicates missing values.
"""
evaluator = get_oracle(
bundle, context_directory, output, testcase, unexpected_status=unexpected_status
Expand All @@ -119,7 +119,7 @@ def _evaluate_channel(

if not should_report_case and is_correct:
# We do report that a test is correct, to set the status.
return True
return False

expected = evaluation_result.readable_expected
out.add(StartTest(expected=expected, channel=channel))
Expand All @@ -128,9 +128,10 @@ def _evaluate_channel(
for message in evaluation_result.messages:
out.add(AppendMessage(message=message))

# Report missing output
missing = False
if actual is None:
out.add(AppendMessage(message=get_i18n_string("judge.evaluation.early-exit")))
out.add(AppendMessage(message=get_i18n_string("judge.evaluation.missing")))
missing = True
elif should_report_case and timeout and not is_correct:
status.human = get_i18n_string("judge.evaluation.time-limit")
status.enum = Status.TIME_LIMIT_EXCEEDED
Expand All @@ -143,7 +144,7 @@ def _evaluate_channel(
# Close the test.
out.add(CloseTest(generated=evaluation_result.readable_actual, status=status))

return is_correct
return missing


def evaluate_context_results(
Expand Down Expand Up @@ -210,17 +211,15 @@ def evaluate_context_results(
could_delete = all(deletions)

# Add a message indicating there were missing values.
missing_values = []
missing_values = None
if not could_delete:
_logger.warning("Missing output in context testcase.")
missing_values.append(
AppendMessage(message=get_i18n_string("judge.evaluation.early-exit"))
)
missing_values = []

Check warning on line 217 in tested/judge/evaluation.py

View check run for this annotation

Codecov / codecov/patch

tested/judge/evaluation.py#L217

Added line #L217 was not covered by tests
missing_values.append(
EscalateStatus(
status=StatusMessage(
enum=Status.WRONG,
human=get_i18n_string("judge.evaluation.missing.output"),
human=get_i18n_string("judge.evaluation.missing"),
)
)
)
Expand Down Expand Up @@ -263,7 +262,7 @@ def evaluate_context_results(
actual_stdout = safe_get(stdout_, i)
actual_value = safe_get(values, i)

_evaluate_channel(
missing_file = _evaluate_channel(
bundle,
context_dir,
t_col,
Expand All @@ -273,7 +272,7 @@ def evaluate_context_results(
timeout=exec_results.timeout,
memory=exec_results.memory,
)
_evaluate_channel(
missing_stderr = _evaluate_channel(
bundle,
context_dir,
t_col,
Expand All @@ -283,7 +282,7 @@ def evaluate_context_results(
timeout=exec_results.timeout and len(stderr_) == i + 1,
memory=exec_results.memory and len(stderr_) == i + 1,
)
_evaluate_channel(
missing_exception = _evaluate_channel(
bundle,
context_dir,
t_col,
Expand All @@ -294,7 +293,7 @@ def evaluate_context_results(
timeout=exec_results.timeout and len(exceptions) == i + 1,
memory=exec_results.memory and len(exceptions) == i + 1,
)
_evaluate_channel(
missing_stdout = _evaluate_channel(
bundle,
context_dir,
t_col,
Expand All @@ -304,7 +303,7 @@ def evaluate_context_results(
timeout=exec_results.timeout and len(stdout_) == i + 1,
memory=exec_results.memory and len(stdout_) == i + 1,
)
_evaluate_channel(
missing_return = _evaluate_channel(
bundle,
context_dir,
t_col,
Expand All @@ -318,7 +317,7 @@ def evaluate_context_results(

# If this is the last testcase, do the exit channel.
if i == len(context.testcases) - 1:
_evaluate_channel(
missing_exit = _evaluate_channel(
bundle,
context_dir,
t_col,
Expand All @@ -329,12 +328,24 @@ def evaluate_context_results(
memory=exec_results.memory,
)
else:
missing_exit = False
assert (
testcase.output.exit_code == IgnoredChannel.IGNORED
), "Only the last testcase may check the exit code."

# Add messages if there was no output.
if missing_values:
if missing_values is not None:
if not (

Check warning on line 338 in tested/judge/evaluation.py

View check run for this annotation

Codecov / codecov/patch

tested/judge/evaluation.py#L338

Added line #L338 was not covered by tests
missing_file
or missing_stderr
or missing_exception
or missing_stdout
or missing_return
or missing_exit
):
t_col.add(

Check warning on line 346 in tested/judge/evaluation.py

View check run for this annotation

Codecov / codecov/patch

tested/judge/evaluation.py#L346

Added line #L346 was not covered by tests
AppendMessage(message=get_i18n_string("judge.evaluation.missing"))
)
for u in missing_values:
t_col.add(u)

Expand Down Expand Up @@ -457,10 +468,7 @@ def _add_channel(
updates.append(
CloseTest(
generated="",
status=StatusMessage(
enum=Status.NOT_EXECUTED,
human=get_i18n_string("judge.evaluation.missing.test"),
),
status=StatusMessage(enum=Status.NOT_EXECUTED),
accepted=False,
)
)
Expand All @@ -483,9 +491,7 @@ def complete_evaluation(bundle: Bundle, collector: OutputManager):
assert tab.contexts
for context in tab.contexts[context_start:]:
updates: list[Update] = [
AppendMessage(
message=get_i18n_string("judge.evaluation.missing.context")
)
AppendMessage(message=get_i18n_string("judge.evaluation.not-executed"))
]
if testcase_start == 0:
collector.add(StartContext(description=context.description))
Expand Down

0 comments on commit f25903c

Please sign in to comment.