On Tue, Dec 01, 2020 at 02:08:14PM +0800, Lin Jiaxin wrote:
provide error messages for git bisect
Signed-off-by: Lin Jiaxin ljx.joe@qq.com
lib/error_messages.rb | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 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..dee0fdf --- /dev/null +++ b/lib/error_messages.rb @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'set'
+# get 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 extract_error_messages
- File.open(@file).each_line do |line|
next if extract_error_message(line)
Pls add blank line after next cmd.
next unless @in_stderr
ditto.
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
ditto.
Thanks, Xijian