test-bot: fix undefined method error
The method `fix_encoding!` is private to `Homebrew::Step` but is also required by the `Homebrew.sanitize_output_for_xml` method for truncating overly long logs. Move `fix_encoding!` into the `Homebrew` module to make it accessible from both this method and the `Homebrew::Step` class. This amends commit 343091c828d1e572829b86253d79b326c1986bcd.
This commit is contained in:
parent
a9c0361a1d
commit
a2c23dfec5
@ -43,6 +43,24 @@ module Homebrew
|
|||||||
String.method_defined?(:force_encoding)
|
String.method_defined?(:force_encoding)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ruby_has_encoding?
|
||||||
|
def fix_encoding!(str)
|
||||||
|
# Assume we are starting from a "mostly" UTF-8 string
|
||||||
|
str.force_encoding(Encoding::UTF_8)
|
||||||
|
return str if str.valid_encoding?
|
||||||
|
str.encode!(Encoding::UTF_16, :invalid => :replace)
|
||||||
|
str.encode!(Encoding::UTF_8)
|
||||||
|
end
|
||||||
|
elsif require "iconv"
|
||||||
|
def fix_encoding!(str)
|
||||||
|
Iconv.conv("UTF-8//IGNORE", "UTF-8", str)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def fix_encoding!(str)
|
||||||
|
str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def resolve_test_tap
|
def resolve_test_tap
|
||||||
if tap = ARGV.value("tap")
|
if tap = ARGV.value("tap")
|
||||||
return Tap.fetch(tap)
|
return Tap.fetch(tap)
|
||||||
@ -188,26 +206,6 @@ module Homebrew
|
|||||||
|
|
||||||
exit 1 if ARGV.include?("--fail-fast") && failed?
|
exit 1 if ARGV.include?("--fail-fast") && failed?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
if Homebrew.ruby_has_encoding?
|
|
||||||
def fix_encoding!(str)
|
|
||||||
# Assume we are starting from a "mostly" UTF-8 string
|
|
||||||
str.force_encoding(Encoding::UTF_8)
|
|
||||||
return str if str.valid_encoding?
|
|
||||||
str.encode!(Encoding::UTF_16, :invalid => :replace)
|
|
||||||
str.encode!(Encoding::UTF_8)
|
|
||||||
end
|
|
||||||
elsif require "iconv"
|
|
||||||
def fix_encoding!(str)
|
|
||||||
Iconv.conv("UTF-8//IGNORE", "UTF-8", str)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
def fix_encoding!(str)
|
|
||||||
str
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Test
|
class Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user