Commit 164c6374 authored by Rubén Dávila's avatar Rubén Dávila

Fix broken specs. #3945

parent 78d7c0e0
---
- - match
- 6
- '@@ -6,12 +6,18 @@ module Popen'
- "@@ -6,12 +6,18 @@ module Popen"
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6
- match
- 6
- '@@ -6,12 +6,18 @@ module Popen'
- "@@ -6,12 +6,18 @@ module Popen"
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6
- -
- 6
- |
<span id="LC2" class="line"> </span>
- |2
<span id="LC6" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6
-
- 6
- |
<span id="LC2" class="line"> </span>
- |2
<span id="LC6" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6
- -
- 7
- |
<span id="LC3" class="line"> <span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>
- |2
<span id="LC7" class="line"> <span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7
-
- 7
- |
<span id="LC3" class="line"> <span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>
- |2
<span id="LC7" class="line"> <span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7
- -
- 8
- |
<span id="LC4" class="line"> <span class="k">unless</span> <span class="n">cmd</span><span class="p">.</span><span class="nf">is_a?</span><span class="p">(</span><span class="no">Array</span><span class="p">)</span></span>
- |2
<span id="LC8" class="line"> <span class="k">unless</span> <span class="n">cmd</span><span class="p">.</span><span class="nf">is_a?</span><span class="p">(</span><span class="no">Array</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8
-
- 8
- |
<span id="LC4" class="line"> <span class="k">unless</span> <span class="n">cmd</span><span class="p">.</span><span class="nf">is_a?</span><span class="p">(</span><span class="no">Array</span><span class="p">)</span></span>
- |2
<span id="LC8" class="line"> <span class="k">unless</span> <span class="n">cmd</span><span class="p">.</span><span class="nf">is_a?</span><span class="p">(</span><span class="no">Array</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8
- - old
- 9
- |
- <span id="LC5" class="line"><span class="k">raise</span> <span class="s2">&quot;System commands must be given as an array of strings&quot;</span></span>
-<span id="LC9" class="line"> <span class="k">raise</span> <span class="s2">&quot;System commands must be given as an array of strings&quot;</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9
- new
- 9
- |
+ <span id="LC6" class="line"><span class="k">raise</span> <span class="idiff">RuntimeError, </span><span class="s2">&quot;System commands must be given as an array of strings&quot;</span></span>
+<span id="LC9" class="line"> <span class="k">raise</span> <span class="no">RuntimeError</span><span class="p">,</span> <span class="s2">&quot;System commands must be given as an array of strings&quot;</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9
- -
- 10
- |
<span id="LC7" class="line"> <span class="k">end</span></span>
- |2
<span id="LC10" class="line"> <span class="k">end</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10
-
- 10
- |
<span id="LC7" class="line"> <span class="k">end</span></span>
- |2
<span id="LC10" class="line"> <span class="k">end</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10
- -
- 11
- |
<span id="LC8" class="line"> </span>
- |2
<span id="LC11" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_11_11
-
- 11
- |
<span id="LC8" class="line"> </span>
- |2
<span id="LC11" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_11_11
- -
- 12
- |
<span id="LC9" class="line"> <span class="n">path</span> <span class="o">||=</span> <span class="no">Dir</span><span class="p">.</span><span class="nf">pwd</span></span>
- |2
<span id="LC12" class="line"> <span class="n">path</span> <span class="o">||=</span> <span class="no">Dir</span><span class="p">.</span><span class="nf">pwd</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_12_12
-
- 12
- |
<span id="LC9" class="line"> <span class="n">path</span> <span class="o">||=</span> <span class="no">Dir</span><span class="p">.</span><span class="nf">pwd</span></span>
- |2
<span id="LC12" class="line"> <span class="n">path</span> <span class="o">||=</span> <span class="no">Dir</span><span class="p">.</span><span class="nf">pwd</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_12_12
- - old
- 13
- |
- <span id="LC10" class="line"><span class="n">vars</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">&quot;PWD&quot;</span> <span class="o">=&gt;</span> <span class="n">path</span> <span class="p">}</span></span>
-<span id="LC13" class="line"> <span class="n">vars</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">&quot;PWD&quot;</span> <span class="o">=&gt;</span> <span class="n">path</span> <span class="p">}</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_13_13
- old
-
......@@ -89,12 +89,12 @@
- - old
- 14
- |
- <span id="LC11" class="line"><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">chdir: </span><span class="n">path</span> <span class="p">}</span></span>
-<span id="LC14" class="line"> <span class="n">options</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">chdir: </span><span class="n">path</span> <span class="p">}</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_13
- new
- 13
- |
+<span id="LC12" class="line"></span>
+<span id="LC13" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_13
- -
-
......@@ -103,7 +103,7 @@
- new
- 14
- |
+ <span id="LC13" class="line"><span class="n">vars</span> <span class="o">=</span> <span class="p">{</span></span>
+<span id="LC14" class="line"> <span class="n">vars</span> <span class="o">=</span> <span class="p">{</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_14
- -
-
......@@ -112,7 +112,7 @@
- new
- 15
- |
+ <span id="LC14" class="line"><span class="s2">&quot;PWD&quot;</span> <span class="o">=&gt;</span> <span class="n">path</span></span>
+<span id="LC15" class="line"> <span class="s2">&quot;PWD&quot;</span> <span class="o">=&gt;</span> <span class="n">path</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15
- -
-
......@@ -121,7 +121,7 @@
- new
- 16
- |
+ <span id="LC15" class="line"><span class="p">}</span></span>
+<span id="LC16" class="line"> <span class="p">}</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_16
- -
-
......@@ -130,7 +130,7 @@
- new
- 17
- |
+<span id="LC16" class="line"></span>
+<span id="LC17" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_17
- -
-
......@@ -139,7 +139,7 @@
- new
- 18
- |
+ <span id="LC17" class="line"><span class="n">options</span> <span class="o">=</span> <span class="p">{</span></span>
+<span id="LC18" class="line"> <span class="n">options</span> <span class="o">=</span> <span class="p">{</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_18
- -
-
......@@ -148,7 +148,7 @@
- new
- 19
- |
+ <span id="LC18" class="line"><span class="ss">chdir: </span><span class="n">path</span></span>
+<span id="LC19" class="line"> <span class="ss">chdir: </span><span class="n">path</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_19
- -
-
......@@ -157,75 +157,75 @@
- new
- 20
- |
+ <span id="LC19" class="line"><span class="p">}</span></span>
+<span id="LC20" class="line"> <span class="p">}</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_20
- -
- 15
- |
<span id="LC20" class="line"> </span>
- |2
<span id="LC21" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_21
-
- 21
- |
<span id="LC20" class="line"> </span>
- |2
<span id="LC21" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_21
- -
- 16
- |
<span id="LC21" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- |2
<span id="LC22" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_16_22
-
- 22
- |
<span id="LC21" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- |2
<span id="LC22" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_16_22
- -
- 17
- |
<span id="LC22" class="line"> <span class="no">FileUtils</span><span class="p">.</span><span class="nf">mkdir_p</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- |2
<span id="LC23" class="line"> <span class="no">FileUtils</span><span class="p">.</span><span class="nf">mkdir_p</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_17_23
-
- 23
- |
<span id="LC22" class="line"> <span class="no">FileUtils</span><span class="p">.</span><span class="nf">mkdir_p</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- |2
<span id="LC23" class="line"> <span class="no">FileUtils</span><span class="p">.</span><span class="nf">mkdir_p</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_17_23
- - match
- 19
- '@@ -19,6 +25,7 @@ module Popen'
- "@@ -19,6 +25,7 @@ module Popen"
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_19_25
- match
- 25
- '@@ -19,6 +25,7 @@ module Popen'
- "@@ -19,6 +25,7 @@ module Popen"
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_19_25
- -
- 19
- |
<span id="LC24" class="line"> </span>
- |2
<span id="LC25" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_19_25
-
- 25
- |
<span id="LC24" class="line"> </span>
- |2
<span id="LC25" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_19_25
- -
- 20
- |
<span id="LC25" class="line"> <span class="vi">@cmd_output</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span></span>
- |2
<span id="LC26" class="line"> <span class="vi">@cmd_output</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_20_26
-
- 26
- |
<span id="LC25" class="line"> <span class="vi">@cmd_output</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span></span>
- |2
<span id="LC26" class="line"> <span class="vi">@cmd_output</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_20_26
- -
- 21
- |
<span id="LC26" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>
- |2
<span id="LC27" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_21_27
-
- 27
- |
<span id="LC26" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>
- |2
<span id="LC27" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_21_27
- -
-
......@@ -234,37 +234,35 @@
- new
- 28
- |
+<span id="LC27" class="line"></span>
+<span id="LC28" class="line"></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_22_28
- -
- 22
- |
<span id="LC28" class="line"> <span class="no">Open3</span><span class="p">.</span><span class="nf">popen3</span><span class="p">(</span><span class="n">vars</span><span class="p">,</span> <span class="o">*</span><span class="n">cmd</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="p">,</span> <span class="n">wait_thr</span><span class="o">|</span></span>
- |2
<span id="LC29" class="line"> <span class="no">Open3</span><span class="p">.</span><span class="nf">popen3</span><span class="p">(</span><span class="n">vars</span><span class="p">,</span> <span class="o">*</span><span class="n">cmd</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="p">,</span> <span class="n">wait_thr</span><span class="o">|</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_22_29
-
- 29
- |
<span id="LC28" class="line"> <span class="no">Open3</span><span class="p">.</span><span class="nf">popen3</span><span class="p">(</span><span class="n">vars</span><span class="p">,</span> <span class="o">*</span><span class="n">cmd</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="p">,</span> <span class="n">wait_thr</span><span class="o">|</span></span>
- |2
<span id="LC29" class="line"> <span class="no">Open3</span><span class="p">.</span><span class="nf">popen3</span><span class="p">(</span><span class="n">vars</span><span class="p">,</span> <span class="o">*</span><span class="n">cmd</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="p">,</span> <span class="n">wait_thr</span><span class="o">|</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_22_29
- -
- 23
- |
<span id="LC29" class="line"> <span class="vi">@cmd_output</span> <span class="o">&lt;&lt;</span> <span class="n">stdout</span><span class="p">.</span><span class="nf">read</span></span>
- |2
<span id="LC30" class="line"> <span class="vi">@cmd_output</span> <span class="o">&lt;&lt;</span> <span class="n">stdout</span><span class="p">.</span><span class="nf">read</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_23_30
-
- 30
- |
<span id="LC29" class="line"> <span class="vi">@cmd_output</span> <span class="o">&lt;&lt;</span> <span class="n">stdout</span><span class="p">.</span><span class="nf">read</span></span>
- |2
<span id="LC30" class="line"> <span class="vi">@cmd_output</span> <span class="o">&lt;&lt;</span> <span class="n">stdout</span><span class="p">.</span><span class="nf">read</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_23_30
- -
- 24
- <span id="LC30" class="line"> <span class="vi">@cmd_output</span> <span
class="o">&lt;&lt;</span> <span class="n">stderr</span><span class="p">.</span><span
class="nf">read</span></span>
- |2
<span id="LC31" class="line"> <span class="vi">@cmd_output</span> <span class="o">&lt;&lt;</span> <span class="n">stderr</span><span class="p">.</span><span class="nf">read</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_24_31
-
- 31
- <span id="LC30" class="line"> <span class="vi">@cmd_output</span> <span
class="o">&lt;&lt;</span> <span class="n">stderr</span><span class="p">.</span><span
class="nf">read</span></span>
- |2
<span id="LC31" class="line"> <span class="vi">@cmd_output</span> <span class="o">&lt;&lt;</span> <span class="n">stderr</span><span class="p">.</span><span class="nf">read</span></span>
- 2f6fcd96b88b36ce98c38da085c795a27d92a3dd_24_31
......@@ -4,11 +4,12 @@ describe DiffHelper do
include RepoHelpers
let(:project) { create(:project) }
let(:repository) { project.repository }
let(:commit) { project.commit(sample_commit.id) }
let(:diffs) { commit.diffs }
let(:diff) { diffs.first }
let(:diff_refs) { [commit.parent.id, commit.id] }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs, project.repository) }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs, repository) }
describe 'diff_hard_limit_enabled?' do
it 'should return true if param is provided' do
......@@ -45,41 +46,41 @@ describe DiffHelper do
describe 'safe_diff_files' do
it 'should return all files from a commit that is smaller than safe limits' do
expect(safe_diff_files(diffs).length).to eq(2)
expect(safe_diff_files(diffs, diff_refs, repository).length).to eq(2)
end
it 'should return only the first file if the diff line count in the 2nd file takes the total beyond safe limits' do
allow(diffs[1].diff).to receive(:lines).and_return([""] * 4999) #simulate 4999 lines
expect(safe_diff_files(diffs).length).to eq(1)
expect(safe_diff_files(diffs, diff_refs, repository).length).to eq(1)
end
it 'should return all files from a commit that is beyond safe limit for numbers of lines if force diff is true' do
allow(controller).to receive(:params) { { force_show_diff: true } }
allow(diffs[1].diff).to receive(:lines).and_return([""] * 4999) #simulate 4999 lines
expect(safe_diff_files(diffs).length).to eq(2)
expect(safe_diff_files(diffs, diff_refs, repository).length).to eq(2)
end
it 'should return only the first file if the diff line count in the 2nd file takes the total beyond hard limits' do
allow(controller).to receive(:params) { { force_show_diff: true } }
allow(diffs[1].diff).to receive(:lines).and_return([""] * 49999) #simulate 49999 lines
expect(safe_diff_files(diffs).length).to eq(1)
expect(safe_diff_files(diffs, diff_refs, repository).length).to eq(1)
end
it 'should return only a safe number of file diffs if a commit touches more files than the safe limits' do
large_diffs = diffs * 100 #simulate 200 diffs
expect(safe_diff_files(large_diffs).length).to eq(100)
expect(safe_diff_files(large_diffs, diff_refs, repository).length).to eq(100)
end
it 'should return all file diffs if a commit touches more files than the safe limits but force diff is true' do
allow(controller).to receive(:params) { { force_show_diff: true } }
large_diffs = diffs * 100 #simulate 200 diffs
expect(safe_diff_files(large_diffs).length).to eq(200)
expect(safe_diff_files(large_diffs, diff_refs, repository).length).to eq(200)
end
it 'should return a limited file diffs if a commit touches more files than the hard limits and force diff is true' do
allow(controller).to receive(:params) { { force_show_diff: true } }
very_large_diffs = diffs * 1000 #simulate 2000 diffs
expect(safe_diff_files(very_large_diffs).length).to eq(1000)
expect(safe_diff_files(very_large_diffs, diff_refs, repository).length).to eq(1000)
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