提交 c26b1265 编写于 作者: L Lin Jen-Shin

Make sure @stream.each_line would tag Encoding.default_external

上级 ee3b0c3a
......@@ -15,6 +15,8 @@ module Gitlab
def initialize
@stream = yield
@stream.binmode
# Ci::Ansi2html::Converter would read from @stream directly
@stream.set_encoding(Encoding.default_external)
end
def valid?
......
......@@ -34,12 +34,12 @@ describe Gitlab::Ci::Trace::Stream do
end
context 'when the trace contains ANSI sequence and Unicode' do
let(:stream) do
described_class.new do
File.open(expand_fixture_path('trace/ansi-sequence-and-unicode'))
end
let(:io) do
File.open(expand_fixture_path('trace/ansi-sequence-and-unicode'))
end
let(:stream) { described_class.new { io } }
it 'forwards to the next linefeed, case 1' do
stream.limit(7)
......@@ -57,6 +57,16 @@ describe Gitlab::Ci::Trace::Stream do
expect(result).to eq("\e[01;32m許功蓋\e[0m\n")
expect(result.encoding).to eq(Encoding.default_external)
end
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/30796
it 'reads in binary, output as Encoding.default_external' do
stream.limit(29)
result = io.read # Ci::Ansi2html::Converter would read with each_line
expect(result).to eq("\e[01;32m許功蓋\e[0m\n")
expect(result.encoding).to eq(Encoding.default_external)
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册