Improve PyLint RegEx to match single lines
* Also return more detailed results for further analysis
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
class PyLintAdapter < TestingFrameworkAdapter
|
class PyLintAdapter < TestingFrameworkAdapter
|
||||||
REGEXP = /Your code has been rated at (-?\d+\.?\d*)\/(\d+\.?\d*)/
|
REGEXP = /Your code has been rated at (-?\d+\.?\d*)\/(\d+\.?\d*)/
|
||||||
ASSERTION_ERROR_REGEXP = /^.*?\(.*?,\ (.*?),.*?\)\ (.*?)$/m
|
ASSERTION_ERROR_REGEXP = /^.*?\([^,]*?,\ ([^,]*?),[^,]*?\)\ (.*?)$/
|
||||||
|
|
||||||
def self.framework_name
|
def self.framework_name
|
||||||
'PyLint'
|
'PyLint'
|
||||||
@ -14,21 +14,22 @@ class PyLintAdapter < TestingFrameworkAdapter
|
|||||||
else
|
else
|
||||||
captures = regex_match.captures.map(&:to_f)
|
captures = regex_match.captures.map(&:to_f)
|
||||||
count = captures.second
|
count = captures.second
|
||||||
passed = captures.first
|
passed = captures.first >= 0 ? captures.first : 0
|
||||||
failed = count - passed
|
failed = count - passed
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
assertion_error_matches = Timeout.timeout(2.seconds) do
|
assertion_error_matches = Timeout.timeout(2.seconds) do
|
||||||
output[:stdout].scan(ASSERTION_ERROR_REGEXP).map { |match|
|
output[:stdout].scan(ASSERTION_ERROR_REGEXP).map do |match|
|
||||||
test = match.first.strip
|
test = match.first.strip
|
||||||
description = match.second.strip
|
description = match.second.strip
|
||||||
"#{test}: #{description}"
|
{test: test, description: description}
|
||||||
}.flatten || []
|
end || []
|
||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
assertion_error_matches = []
|
assertion_error_matches = []
|
||||||
end
|
end
|
||||||
{count: count, failed: failed, error_messages: assertion_error_matches}
|
concatenated_errors = assertion_error_matches.map { |result| "#{result[:test]}: #{result[:description]}" }.flatten
|
||||||
|
{count: count, failed: failed, error_messages: concatenated_errors, detailed_linter_results: assertion_error_matches}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user