Add timeout for PyLint and PyUnit Adapter

This commit is contained in:
Sebastian Serth
2020-05-13 01:27:33 +02:00
parent d1856c443f
commit ba8e08aee4
2 changed files with 25 additions and 13 deletions

View File

@ -11,11 +11,17 @@ class PyLintAdapter < TestingFrameworkAdapter
count = captures.second count = captures.second
passed = captures.first passed = captures.first
failed = count - passed failed = count - passed
begin
Timeout.timeout(2.seconds) do
assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP).map { |match| assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP).map { |match|
test = match.first.strip test = match.first.strip
description = match.second.strip description = match.second.strip
"#{test}: #{description}" "#{test}: #{description}"
}.flatten || [] }.flatten || []
end
rescue Timeout::Error
assertion_error_matches = []
end
{count: count, failed: failed, error_messages: assertion_error_matches} {count: count, failed: failed, error_messages: assertion_error_matches}
end end
end end

View File

@ -14,6 +14,8 @@ class PyUnitAdapter < TestingFrameworkAdapter
failed = failures_matches ? failures_matches.captures.try(:first).to_i : 0 failed = failures_matches ? failures_matches.captures.try(:first).to_i : 0
error_matches = ERRORS_REGEXP.match(output[:stderr]) error_matches = ERRORS_REGEXP.match(output[:stderr])
errors = error_matches ? error_matches.captures.try(:first).to_i : 0 errors = error_matches ? error_matches.captures.try(:first).to_i : 0
begin
Timeout.timeout(2.seconds) do
assertion_error_matches = output[:stderr].scan(ASSERTION_ERROR_REGEXP).map { |match| assertion_error_matches = output[:stderr].scan(ASSERTION_ERROR_REGEXP).map { |match|
testname = match[1] testname = match[1]
error = match[3].strip error = match[3].strip
@ -24,6 +26,10 @@ class PyUnitAdapter < TestingFrameworkAdapter
"#{testname}: #{error}" "#{testname}: #{error}"
end end
}.flatten || [] }.flatten || []
end
rescue Timeout::Error
assertion_error_matches = []
end
{count: count, failed: failed + errors, error_messages: assertion_error_matches} {count: count, failed: failed + errors, error_messages: assertion_error_matches}
end end
end end