Suppress encoding errors in test-bot log files
This commit is contained in:
parent
91ccd8435c
commit
7f230dfaf8
@ -129,7 +129,7 @@ module Homebrew
|
|||||||
puts_result
|
puts_result
|
||||||
|
|
||||||
if File.exist?(log)
|
if File.exist?(log)
|
||||||
@output = File.read(log)
|
@output = fix_encoding File.read(log)
|
||||||
if has_output? and (failed? or @puts_output_on_success)
|
if has_output? and (failed? or @puts_output_on_success)
|
||||||
puts @output
|
puts @output
|
||||||
end
|
end
|
||||||
@ -138,6 +138,22 @@ module Homebrew
|
|||||||
|
|
||||||
exit 1 if ARGV.include?("--fail-fast") && @status == :failed
|
exit 1 if ARGV.include?("--fail-fast") && @status == :failed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
if String.method_defined?(:force_encoding)
|
||||||
|
def fix_encoding(str)
|
||||||
|
return str if str.valid_encoding?
|
||||||
|
# Assume we are starting from a "mostly" UTF-8 string
|
||||||
|
str.force_encoding(Encoding::UTF_8)
|
||||||
|
str.encode!(Encoding::UTF_16, :invalid => :replace, :undef => :replace)
|
||||||
|
str.encode!(Encoding::UTF_8)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def fix_encoding(str)
|
||||||
|
str
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Test
|
class Test
|
||||||
@ -630,12 +646,11 @@ module Homebrew
|
|||||||
testcase.attributes['time'] = step.time
|
testcase.attributes['time'] = step.time
|
||||||
failure = testcase.add_element 'failure' if step.failed?
|
failure = testcase.add_element 'failure' if step.failed?
|
||||||
if step.has_output?
|
if step.has_output?
|
||||||
# Remove invalid XML CData characters from step output.
|
|
||||||
output = step.output
|
output = step.output
|
||||||
if output.respond_to?(:force_encoding) && !output.valid_encoding?
|
|
||||||
output.force_encoding(Encoding::UTF_8)
|
# Remove invalid XML CData characters from step output.
|
||||||
end
|
|
||||||
output = output.delete("\000\a\b\e\f")
|
output = output.delete("\000\a\b\e\f")
|
||||||
|
|
||||||
if output.bytesize > BYTES_IN_1_MEGABYTE
|
if output.bytesize > BYTES_IN_1_MEGABYTE
|
||||||
output = "truncated output to 1MB:\n" \
|
output = "truncated output to 1MB:\n" \
|
||||||
+ output.slice(-BYTES_IN_1_MEGABYTE, BYTES_IN_1_MEGABYTE)
|
+ output.slice(-BYTES_IN_1_MEGABYTE, BYTES_IN_1_MEGABYTE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user