diff --git a/lib/py_lint_adapter.rb b/lib/py_lint_adapter.rb index c9a50f00..4be814c1 100644 --- a/lib/py_lint_adapter.rb +++ b/lib/py_lint_adapter.rb @@ -11,11 +11,17 @@ class PyLintAdapter < TestingFrameworkAdapter count = captures.second passed = captures.first failed = count - passed - assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP).map { |match| - test = match.first.strip - description = match.second.strip - "#{test}: #{description}" - }.flatten || [] + begin + Timeout.timeout(2.seconds) do + assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP).map { |match| + test = match.first.strip + description = match.second.strip + "#{test}: #{description}" + }.flatten || [] + end + rescue Timeout::Error + assertion_error_matches = [] + end {count: count, failed: failed, error_messages: assertion_error_matches} end end diff --git a/lib/py_unit_adapter.rb b/lib/py_unit_adapter.rb index 8b38a8d9..5c30dd3d 100644 --- a/lib/py_unit_adapter.rb +++ b/lib/py_unit_adapter.rb @@ -14,16 +14,22 @@ class PyUnitAdapter < TestingFrameworkAdapter failed = failures_matches ? failures_matches.captures.try(:first).to_i : 0 error_matches = ERRORS_REGEXP.match(output[:stderr]) errors = error_matches ? error_matches.captures.try(:first).to_i : 0 - assertion_error_matches = output[:stderr].scan(ASSERTION_ERROR_REGEXP).map { |match| - testname = match[1] - error = match[3].strip + begin + Timeout.timeout(2.seconds) do + assertion_error_matches = output[:stderr].scan(ASSERTION_ERROR_REGEXP).map { |match| + testname = match[1] + error = match[3].strip - if testname == 'test_assess' - error - else - "#{testname}: #{error}" + if testname == 'test_assess' + error + else + "#{testname}: #{error}" + end + }.flatten || [] end - }.flatten || [] + rescue Timeout::Error + assertion_error_matches = [] + end {count: count, failed: failed + errors, error_messages: assertion_error_matches} end end