summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-07-21 13:04:18 +0100
committerNick Thomas <nick@gitlab.com>2017-07-22 07:12:19 +0100
commit4bda5b502de35b7032f8c49a340325aeeb0d7ebe (patch)
tree087887974ab9796546f2ac225e708b0ac803e23d /spec
parent754d8caeefdcb887a8a955155cbec436f7ae13c9 (diff)
downloadgitlab-ce-4bda5b502de35b7032f8c49a340325aeeb0d7ebe.tar.gz
Short-circuit build coverage extraction for empty regexes
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ci/trace/stream_spec.rb22
-rw-r--r--spec/lib/gitlab/untrusted_regexp_spec.rb6
2 files changed, 25 insertions, 3 deletions
diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb
index 3a132fb9989..8b925fd4e22 100644
--- a/spec/lib/gitlab/ci/trace/stream_spec.rb
+++ b/spec/lib/gitlab/ci/trace/stream_spec.rb
@@ -307,5 +307,27 @@ describe Gitlab::Ci::Trace::Stream do
it { is_expected.to eq('65') }
end
+
+ context 'empty regex' do
+ let(:data) { 'foo' }
+ let(:regex) { '' }
+
+ it 'skips processing' do
+ expect(stream).not_to receive(:read)
+
+ is_expected.to be_nil
+ end
+ end
+
+ context 'nil regex' do
+ let(:data) { 'foo' }
+ let(:regex) { nil }
+
+ it 'skips processing' do
+ expect(stream).not_to receive(:read)
+
+ is_expected.to be_nil
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/untrusted_regexp_spec.rb b/spec/lib/gitlab/untrusted_regexp_spec.rb
index a2ef2a27e4c..21d47b7897a 100644
--- a/spec/lib/gitlab/untrusted_regexp_spec.rb
+++ b/spec/lib/gitlab/untrusted_regexp_spec.rb
@@ -55,7 +55,7 @@ describe Gitlab::UntrustedRegexp do
let(:text) { 'foo' }
it 'returns an array of empty matches' do
- is_expected.to eq(['', '', ''])
+ is_expected.to eq([''])
end
end
@@ -63,8 +63,8 @@ describe Gitlab::UntrustedRegexp do
let(:regexp) { '()' }
let(:text) { 'foo' }
- it 'returns arrays of empty matches in an array' do
- is_expected.to eq([[''], [''], ['']])
+ it 'returns an array of empty matches in an array' do
+ is_expected.to eq([['']])
end
end