From faa5dffbcc0a2649ee8f427905d45d7061975bcb Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 13 Apr 2017 02:11:35 +0800 Subject: After Trace#limit, we seek to the next line in case of breaking ANSI sequence or Unicode --- spec/lib/gitlab/ci/trace/stream_spec.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'spec/lib') diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index 2e57ccef182..61ac76401ea 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -21,7 +21,7 @@ describe Gitlab::Ci::Trace::Stream do 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) expect(stream.tell).to eq(0) @@ -32,6 +32,26 @@ describe Gitlab::Ci::Trace::Stream do expect(stream.tell).to eq(6) 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 describe '#append' do -- cgit v1.2.1 From 0a3c98a7e3b76f51902612ae302e821f54eadd74 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 13 Apr 2017 22:23:12 +0800 Subject: Update tests for the fact that we would skip one line --- spec/lib/gitlab/ci/trace/stream_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/lib') diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index 61ac76401ea..9e3bd6d662f 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -17,12 +17,12 @@ describe Gitlab::Ci::Trace::Stream do describe '#limit' do let(:stream) do described_class.new do - StringIO.new("12345678") + StringIO.new((1..8).to_a.join("\n")) end end it 'if size is larger we start from beginning' do - stream.limit(10) + stream.limit(20) expect(stream.tell).to eq(0) end @@ -30,7 +30,7 @@ describe Gitlab::Ci::Trace::Stream do it 'if size is smaller we start from the end' do stream.limit(2) - expect(stream.tell).to eq(6) + expect(stream.raw).to eq("8") end context 'when the trace contains ANSI sequence and Unicode' do -- cgit v1.2.1