From a2c23dfec569c6e73d90cb20c7d4c26cced258d5 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Wed, 6 Apr 2016 06:22:22 +0200 Subject: [PATCH] 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. --- Library/Homebrew/cmd/test-bot.rb | 38 +++++++++++++++----------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb index 067e7da97c..8f26352820 100644 --- a/Library/Homebrew/cmd/test-bot.rb +++ b/Library/Homebrew/cmd/test-bot.rb @@ -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