Skip to content
Snippets Groups Projects
Commit a2c23dfe authored by Martin Afanasjew's avatar Martin Afanasjew
Browse files

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 343091c8.
parent a9c0361a
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,24 @@ module Homebrew
String.method_defined?(:force_encoding)
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
if tap = ARGV.value("tap")
return Tap.fetch(tap)
......@@ -188,26 +206,6 @@ module Homebrew
exit 1 if ARGV.include?("--fail-fast") && failed?
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
class Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment