Skip to content

Commit 444174f

Browse files
committed
TestingFrameworkAdapter: Omit empty error_messages array
Previously, it was language-dependent whether the `error_messages` was shown in case of an error or not. Now, we omit it if no error message is included.
1 parent d146258 commit 444174f

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

docs/remote_evaluation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ components:
354354
readOnly: true
355355
error_messages:
356356
type: array
357-
description: 'If present, the `error_messages` lists test errors extracted by CodeOcean. The array is omitted if no test failed (`failed` = 0) and could be empty if no error was extracted.'
357+
description: 'If present, the `error_messages` lists test errors extracted by CodeOcean. The array is omitted if no test failed (`failed` = 0) or if no error was extracted.'
358358
minItems: 0
359359
items:
360360
type: string

lib/julia_adapter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def parse_test_results(output)
4242
else
4343
error_matches = output.to_enum(:scan, ASSERTION_ERROR_REGEXP).map { Regexp.last_match } || []
4444
messages = error_matches.pluck(:message)
45-
{count:, failed:, error_messages: messages.flatten.compact_blank}
45+
{count:, failed:, error_messages: messages.flatten.compact_blank.presence}
4646
end
4747
end
4848

4949
def parse_error(output)
5050
error_matches = output.to_enum(:scan, LOAD_ERROR_REGEXP).map { Regexp.last_match } || []
5151
messages = error_matches.pluck(:message)
52-
{count: 1, failed: 1, error_messages: messages.flatten.compact_blank}
52+
{count: 1, failed: 1, error_messages: messages.flatten.compact_blank.presence}
5353
end
5454
end

lib/junit5_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def parse_output(output)
1616
{count:, passed: count}
1717
else
1818
error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP) || []
19-
{count:, failed:, error_messages: error_matches.flatten.compact_blank}
19+
{count:, failed:, error_messages: error_matches.flatten.compact_blank.presence}
2020
end
2121
end
2222
end

lib/junit_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def parse_output(output)
1717
count = output[:stdout].scan(COUNT_REGEXP).try(:last).try(:first).try(:to_i) || 0
1818
failed = output[:stdout].scan(FAILURES_REGEXP).try(:last).try(:first).try(:to_i) || 0
1919
error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP) || []
20-
{count:, failed:, error_messages: error_matches.flatten.compact_blank}
20+
{count:, failed:, error_messages: error_matches.flatten.compact_blank.presence}
2121
end
2222
end
2323
end

lib/py_lint_adapter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def parse_output(output)
4343
{
4444
count:,
4545
failed:,
46-
error_messages: concatenated_errors.flatten.compact_blank,
47-
detailed_linter_results: assertion_error_matches.flatten.compact_blank,
46+
error_messages: concatenated_errors.flatten.compact_blank.presence,
47+
detailed_linter_results: assertion_error_matches.flatten.compact_blank.presence,
4848
}
4949
end
5050

lib/py_unit_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ def parse_output(output)
3232
Sentry.capture_message({stderr: output[:stderr], regex: ASSERTION_ERROR_REGEXP}.to_json)
3333
assertion_error_matches = []
3434
end
35-
{count:, failed: failed + errors, error_messages: assertion_error_matches.flatten.compact_blank}
35+
{count:, failed: failed + errors, error_messages: assertion_error_matches.flatten.compact_blank.presence}
3636
end
3737
end

lib/py_unit_and_py_lint_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def parse_output(output)
99
if output[:file_role] == 'teacher_defined_linter'
1010
PyLintAdapter.new.parse_output(output)
1111
else
12-
PyUnitAdapter.new.parse_output(output)
12+
1313
end
1414
end
1515

lib/r_script_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def parse_output(output)
1414
passed = captures.second
1515
failed = count - passed
1616
assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP) || []
17-
{count:, failed:, error_messages: assertion_error_matches.flatten.compact_blank}
17+
{count:, failed:, error_messages: assertion_error_matches.flatten.compact_blank.presence}
1818
end
1919
end

0 commit comments

Comments
 (0)