On Tue, Dec 01, 2020 at 07:49:19PM +0800, Lin Jiaxin wrote:
provide error messages for git bisect
Pls give a example with input and output, show how to use this script.
Thanks, Xueliang
Signed-off-by: Lin Jiaxin ljx.joe@qq.com
lib/error_messages.rb | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 lib/error_messages.rb
diff --git a/lib/error_messages.rb b/lib/error_messages.rb new file mode 100644 index 0000000..f59c73a --- /dev/null +++ b/lib/error_messages.rb @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'set'
+# obtain error messages hash +class ErrorMessages
- def initialize(file)
- @file = file
- @seqno = ''
- @in_stderr = false
- @error_line = ''
- @error_details = ''
- @error_message = {}
- @error_messages = Hash.new { |h, k| h[k] = Set.new }
- end
- def obtain_error_messages
- File.open(@file).each_line do |line|
next if extract_error_message(line)
next unless @in_stderr
next unless @error_message['error_line'].downcase =~ /error|warning/
@error_messages[@error_message['error_line']] << @error_message['error_line'] + @error_message['error_details']
- end
- return @error_messages
- end
- private
- def extract_error_message(line)
- if line =~ /^ /
@error_details += line
- else
update_error_message(line)
case line
when /^## ______________([0-9.]+):stderr$/
@in_stderr = true
@seqno = $1
return true
when /^## ______________#{@seqno}:enderr$/
@in_stderr = false
@seqno = ''
add_error_message
end
- end
- end
- def update_error_message(line)
- @error_message['error_line'] = @error_line
- @error_message['error_details'] = @error_details
- @error_line = line
- @error_details = ''
- end
- def add_error_message
- return unless @error_message['error_line'].downcase =~ /error|warning/
- @error_messages[@error_message['error_line']] << @error_message['error_line'] + @error_message['error_details']
- end
+end
2.23.0