diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-29 18:06:15 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-29 18:06:15 +0000 |
commit | cb3e6b9c1b020378b5f94b4c38319a2dc961de01 (patch) | |
tree | 7933db817fb945478151685a393420b44fa52f7c /spec/lib/gitlab/ci/ansi2json_spec.rb | |
parent | dee9315801b5dc49b795d13081086c22622a11ec (diff) | |
download | gitlab-ce-cb3e6b9c1b020378b5f94b4c38319a2dc961de01.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/ansi2json_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/ansi2json_spec.rb | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/spec/lib/gitlab/ci/ansi2json_spec.rb b/spec/lib/gitlab/ci/ansi2json_spec.rb index 3c6bc46436b..3cd448d1aae 100644 --- a/spec/lib/gitlab/ci/ansi2json_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json_spec.rb @@ -12,11 +12,26 @@ describe Gitlab::Ci::Ansi2json do ]) end - it 'adds new line in a separate element' do - expect(convert_json("Hello\nworld")).to eq([ - { offset: 0, content: [{ text: 'Hello' }] }, - { offset: 6, content: [{ text: 'world' }] } - ]) + context 'new lines' do + it 'adds new line when encountering \n' do + expect(convert_json("Hello\nworld")).to eq([ + { offset: 0, content: [{ text: 'Hello' }] }, + { offset: 6, content: [{ text: 'world' }] } + ]) + end + + it 'adds new line when encountering \r\n' do + expect(convert_json("Hello\r\nworld")).to eq([ + { offset: 0, content: [{ text: 'Hello' }] }, + { offset: 7, content: [{ text: 'world' }] } + ]) + end + + it 'replace the current line when encountering \r' do + expect(convert_json("Hello\rworld")).to eq([ + { offset: 0, content: [{ text: 'world' }] } + ]) + end end it 'recognizes color changing ANSI sequences' do @@ -113,10 +128,6 @@ describe Gitlab::Ci::Ansi2json do content: [], section_duration: '01:03', section: 'prepare-script' - }, - { - offset: 63, - content: [] } ]) end @@ -134,10 +145,6 @@ describe Gitlab::Ci::Ansi2json do content: [], section: 'prepare-script', section_duration: '01:03' - }, - { - offset: 56, - content: [] } ]) end @@ -157,7 +164,7 @@ describe Gitlab::Ci::Ansi2json do section_duration: '01:03' }, { - offset: 49, + offset: 91, content: [{ text: 'world' }] } ]) @@ -198,7 +205,7 @@ describe Gitlab::Ci::Ansi2json do expect(convert_json("#{section_start}hello")).to eq([ { offset: 0, - content: [{ text: "#{section_start.gsub("\033[0K", '')}hello" }] + content: [{ text: 'hello' }] } ]) end @@ -211,7 +218,7 @@ describe Gitlab::Ci::Ansi2json do expect(convert_json("#{section_start}hello")).to eq([ { offset: 0, - content: [{ text: "#{section_start.gsub("\033[0K", '').gsub('<', '<')}hello" }] + content: [{ text: 'hello' }] } ]) end @@ -231,10 +238,6 @@ describe Gitlab::Ci::Ansi2json do content: [], section: 'prepare-script', section_duration: '01:03' - }, - { - offset: 95, - content: [] } ]) end @@ -274,7 +277,7 @@ describe Gitlab::Ci::Ansi2json do section_duration: '00:02' }, { - offset: 106, + offset: 155, content: [{ text: 'baz' }], section: 'prepare-script' }, @@ -285,7 +288,7 @@ describe Gitlab::Ci::Ansi2json do section_duration: '01:03' }, { - offset: 158, + offset: 200, content: [{ text: 'world' }] } ]) @@ -318,14 +321,10 @@ describe Gitlab::Ci::Ansi2json do section_duration: '00:02' }, { - offset: 115, + offset: 164, content: [], section: 'prepare-script', section_duration: '01:03' - }, - { - offset: 164, - content: [] } ]) end @@ -380,7 +379,7 @@ describe Gitlab::Ci::Ansi2json do ] end - it 'returns the full line' do + it 'returns the line since last partially processed line' do expect(pass2.lines).to eq(lines) expect(pass2.append).to be_truthy end @@ -399,7 +398,7 @@ describe Gitlab::Ci::Ansi2json do ] end - it 'returns the full line' do + it 'returns the line since last partially processed line' do expect(pass2.lines).to eq(lines) expect(pass2.append).to be_falsey end @@ -416,7 +415,7 @@ describe Gitlab::Ci::Ansi2json do ] end - it 'returns the full line' do + it 'returns a blank line and the next line' do expect(pass2.lines).to eq(lines) expect(pass2.append).to be_falsey end @@ -502,10 +501,6 @@ describe Gitlab::Ci::Ansi2json do content: [], section: 'prepare-script', section_duration: '01:03' - }, - { - offset: 77, - content: [] } ] end |