Commit faa5dffb authored by Lin Jen-Shin's avatar Lin Jen-Shin

After Trace#limit, we seek to the next line in case

of breaking ANSI sequence or Unicode
parent 7629c9ec
...@@ -30,6 +30,7 @@ module Gitlab ...@@ -30,6 +30,7 @@ module Gitlab
last_bytes = stream_size last_bytes = stream_size
end end
stream.seek(-last_bytes, IO::SEEK_END) stream.seek(-last_bytes, IO::SEEK_END)
stream.readline
end end
def append(data, offset) def append(data, offset)
......
.
..
😺
ヾ(´༎ຶД༎ຶ`)ノ
許功蓋
...@@ -21,7 +21,7 @@ describe Gitlab::Ci::Trace::Stream do ...@@ -21,7 +21,7 @@ describe Gitlab::Ci::Trace::Stream do
end end
end end
it 'if size is larger we start from beggining' do it 'if size is larger we start from beginning' do
stream.limit(10) stream.limit(10)
expect(stream.tell).to eq(0) expect(stream.tell).to eq(0)
...@@ -32,6 +32,26 @@ describe Gitlab::Ci::Trace::Stream do ...@@ -32,6 +32,26 @@ describe Gitlab::Ci::Trace::Stream do
expect(stream.tell).to eq(6) expect(stream.tell).to eq(6)
end 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
end
it 'forwards to the next linefeed, case 1' do
stream.limit(7)
expect(stream.raw).to eq('')
end
it 'forwards to the next linefeed, case 2' do
stream.limit(29)
expect(stream.raw).to eq("\e[01;32m許功蓋\e[0m\n")
end
end
end end
describe '#append' do describe '#append' do
......
module FixtureHelpers module FixtureHelpers
def fixture_file(filename) def fixture_file(filename)
return '' if filename.blank? return '' if filename.blank?
file_path = File.expand_path(Rails.root.join('spec/fixtures/', filename)) File.read(expand_fixture_path(filename))
File.read(file_path) end
def expand_fixture_path(filename)
File.expand_path(Rails.root.join('spec/fixtures/', filename))
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment