Skip to content

Commit

Permalink
TestingFrameworkAdapter: Omit empty error_messages array
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MrSerth committed Oct 12, 2024
1 parent d146258 commit a0d9e96
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/remote_evaluation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ components:
readOnly: true
error_messages:
type: array
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.'
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.'
minItems: 0
items:
type: string
Expand Down
4 changes: 2 additions & 2 deletions lib/julia_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def parse_test_results(output)
else
error_matches = output.to_enum(:scan, ASSERTION_ERROR_REGEXP).map { Regexp.last_match } || []
messages = error_matches.pluck(:message)
{count:, failed:, error_messages: messages.flatten.compact_blank}
{count:, failed:, error_messages: messages.flatten.compact_blank.presence}

Check warning on line 45 in lib/julia_adapter.rb

View check run for this annotation

Codecov / codecov/patch

lib/julia_adapter.rb#L45

Added line #L45 was not covered by tests
end
end

def parse_error(output)
error_matches = output.to_enum(:scan, LOAD_ERROR_REGEXP).map { Regexp.last_match } || []
messages = error_matches.pluck(:message)
{count: 1, failed: 1, error_messages: messages.flatten.compact_blank}
{count: 1, failed: 1, error_messages: messages.flatten.compact_blank.presence}

Check warning on line 52 in lib/julia_adapter.rb

View check run for this annotation

Codecov / codecov/patch

lib/julia_adapter.rb#L52

Added line #L52 was not covered by tests
end
end
2 changes: 1 addition & 1 deletion lib/junit5_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def parse_output(output)
{count:, passed: count}
else
error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP) || []
{count:, failed:, error_messages: error_matches.flatten.compact_blank}
{count:, failed:, error_messages: error_matches.flatten.compact_blank.presence}

Check warning on line 19 in lib/junit5_adapter.rb

View check run for this annotation

Codecov / codecov/patch

lib/junit5_adapter.rb#L19

Added line #L19 was not covered by tests
end
end
end
2 changes: 1 addition & 1 deletion lib/junit_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def parse_output(output)
count = output[:stdout].scan(COUNT_REGEXP).try(:last).try(:first).try(:to_i) || 0
failed = output[:stdout].scan(FAILURES_REGEXP).try(:last).try(:first).try(:to_i) || 0
error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP) || []
{count:, failed:, error_messages: error_matches.flatten.compact_blank}
{count:, failed:, error_messages: error_matches.flatten.compact_blank.presence}
end
end
end
4 changes: 2 additions & 2 deletions lib/py_lint_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def parse_output(output)
{
count:,
failed:,
error_messages: concatenated_errors.flatten.compact_blank,
detailed_linter_results: assertion_error_matches.flatten.compact_blank,
error_messages: concatenated_errors.flatten.compact_blank.presence,
detailed_linter_results: assertion_error_matches.flatten.compact_blank.presence,
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/py_unit_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ def parse_output(output)
Sentry.capture_message({stderr: output[:stderr], regex: ASSERTION_ERROR_REGEXP}.to_json)
assertion_error_matches = []
end
{count:, failed: failed + errors, error_messages: assertion_error_matches.flatten.compact_blank}
{count:, failed: failed + errors, error_messages: assertion_error_matches.flatten.compact_blank.presence}
end
end
2 changes: 1 addition & 1 deletion lib/r_script_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def parse_output(output)
passed = captures.second
failed = count - passed
assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP) || []
{count:, failed:, error_messages: assertion_error_matches.flatten.compact_blank}
{count:, failed:, error_messages: assertion_error_matches.flatten.compact_blank.presence}

Check warning on line 17 in lib/r_script_adapter.rb

View check run for this annotation

Codecov / codecov/patch

lib/r_script_adapter.rb#L17

Added line #L17 was not covered by tests
end
end

0 comments on commit a0d9e96

Please sign in to comment.