rake-funnel 0.3.2.pre → 0.4.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/Gemfile +4 -0
- data/README.md +2 -2
- data/lib/rake/funnel/ambiguous_file_error.rb +31 -29
- data/lib/rake/funnel/execution_error.rb +28 -26
- data/lib/rake/funnel/extensions/case/camel_case.rb +24 -19
- data/lib/rake/funnel/extensions/case/pascal_case.rb +24 -19
- data/lib/rake/funnel/extensions/case.rb +3 -3
- data/lib/rake/funnel/extensions/common_path.rb +60 -52
- data/lib/rake/funnel/extensions/disable_colors.rb +33 -27
- data/lib/rake/funnel/extensions/rexml.rb +27 -23
- data/lib/rake/funnel/extensions/shell.rb +92 -56
- data/lib/rake/funnel/extensions/windows_path.rb +15 -11
- data/lib/rake/funnel/framework.rb +11 -16
- data/lib/rake/funnel/integration/progress_report.rb +72 -70
- data/lib/rake/funnel/integration/sync_output.rb +12 -8
- data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +61 -55
- data/lib/rake/funnel/integration/teamcity/progress_report.rb +39 -33
- data/lib/rake/funnel/integration/teamcity/service_messages.rb +46 -40
- data/lib/rake/funnel/integration/teamcity/teamcity.rb +19 -15
- data/lib/rake/funnel/integration/teamcity.rb +3 -5
- data/lib/rake/funnel/support/argument_mapper/key_value_pair.rb +16 -10
- data/lib/rake/funnel/support/argument_mapper/styles/default.rb +39 -31
- data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +41 -33
- data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +55 -47
- data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +41 -33
- data/lib/rake/funnel/support/argument_mapper/styles.rb +3 -5
- data/lib/rake/funnel/support/argument_mapper/switch.rb +16 -10
- data/lib/rake/funnel/support/argument_mapper/value.rb +16 -10
- data/lib/rake/funnel/support/assembly_version/from_version_files.rb +39 -35
- data/lib/rake/funnel/support/assembly_version/languages/cs +5 -5
- data/lib/rake/funnel/support/assembly_version/languages/fs +12 -12
- data/lib/rake/funnel/support/assembly_version/languages/vb +5 -5
- data/lib/rake/funnel/support/assembly_version_writer.rb +56 -52
- data/lib/rake/funnel/support/binary_version_reader.rb +37 -32
- data/lib/rake/funnel/support/copier.rb +31 -27
- data/lib/rake/funnel/support/environments/loader.rb +46 -40
- data/lib/rake/funnel/support/environments.rb +3 -3
- data/lib/rake/funnel/support/internal/finder.rb +55 -51
- data/lib/rake/funnel/support/internal/instantiate_symbol.rb +38 -34
- data/lib/rake/funnel/support/mapper.rb +57 -53
- data/lib/rake/funnel/support/mono.rb +21 -17
- data/lib/rake/funnel/support/msbuild/build_tool.rb +30 -24
- data/lib/rake/funnel/support/msbuild.rb +3 -3
- data/lib/rake/funnel/support/msdeploy/registry_patch.rb +90 -84
- data/lib/rake/funnel/support/msdeploy.rb +3 -3
- data/lib/rake/funnel/support/patch.rb +41 -37
- data/lib/rake/funnel/support/specs_remover.rb +66 -62
- data/lib/rake/funnel/support/template_engine.rb +30 -26
- data/lib/rake/funnel/support/timing/report.rb +95 -89
- data/lib/rake/funnel/support/timing/statistics.rb +32 -26
- data/lib/rake/funnel/support/timing.rb +3 -3
- data/lib/rake/funnel/support/version_info.rb +103 -72
- data/lib/rake/funnel/support/which.rb +19 -15
- data/lib/rake/funnel/support/zipper.rb +53 -49
- data/lib/rake/funnel/tasks/assembly_version.rb +44 -40
- data/lib/rake/funnel/tasks/bin_path.rb +45 -41
- data/lib/rake/funnel/tasks/copy.rb +43 -39
- data/lib/rake/funnel/tasks/environments.rb +89 -89
- data/lib/rake/funnel/tasks/msbuild.rb +55 -51
- data/lib/rake/funnel/tasks/msdeploy.rb +54 -50
- data/lib/rake/funnel/tasks/nunit.rb +52 -48
- data/lib/rake/funnel/tasks/paket.rb +51 -47
- data/lib/rake/funnel/tasks/quick_template.rb +53 -49
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +41 -37
- data/lib/rake/funnel/tasks/timing.rb +108 -104
- data/lib/rake/funnel/tasks/zip.rb +46 -42
- data/lib/rake/funnel/version.rb +1 -1
- data/lib/rake/funnel.rb +7 -7
- data/rake-funnel.gemspec +12 -3
- data/spec/rake/funnel/execution_error_spec.rb +67 -67
- data/spec/rake/funnel/extensions/case/camel_case_spec.rb +17 -17
- data/spec/rake/funnel/extensions/case/pascal_case_spec.rb +17 -17
- data/spec/rake/funnel/extensions/common_path_spec.rb +56 -56
- data/spec/rake/funnel/extensions/disable_colors_spec.rb +33 -33
- data/spec/rake/funnel/extensions/rexml_spec.rb +20 -20
- data/spec/rake/funnel/extensions/shell_spec.rb +237 -237
- data/spec/rake/funnel/extensions/windows_path_spec.rb +5 -5
- data/spec/rake/funnel/integration/progress_report_spec.rb +149 -149
- data/spec/rake/funnel/integration/sync_output_spec.rb +16 -16
- data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +110 -110
- data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +174 -174
- data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +136 -136
- data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +34 -34
- data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +222 -222
- data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +25 -25
- data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +214 -214
- data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +66 -61
- data/spec/rake/funnel/support/assembly_version_writer_spec.rb +140 -140
- data/spec/rake/funnel/support/binary_version_reader_spec.rb +29 -29
- data/spec/rake/funnel/support/copier_spec.rb +58 -58
- data/spec/rake/funnel/support/environments/loader_spec.rb +143 -143
- data/spec/rake/funnel/support/internal/finder_spec.rb +229 -229
- data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +182 -183
- data/spec/rake/funnel/support/mapper_spec.rb +87 -87
- data/spec/rake/funnel/support/mono_spec.rb +57 -57
- data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +21 -21
- data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +139 -139
- data/spec/rake/funnel/support/patch_spec.rb +108 -108
- data/spec/rake/funnel/support/specs_remover/Sample.csproj +28 -28
- data/spec/rake/funnel/support/specs_remover_spec.rb +116 -116
- data/spec/rake/funnel/support/template_engine_spec.rb +65 -65
- data/spec/rake/funnel/support/timing/report_spec.rb +129 -129
- data/spec/rake/funnel/support/version_info_spec.rb +333 -228
- data/spec/rake/funnel/support/which_spec.rb +65 -65
- data/spec/rake/funnel/support/zipper_spec.rb +77 -77
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +45 -45
- data/spec/rake/funnel/tasks/bin_path_spec.rb +52 -52
- data/spec/rake/funnel/tasks/copy_spec.rb +44 -44
- data/spec/rake/funnel/tasks/environments_spec.rb +249 -247
- data/spec/rake/funnel/tasks/msbuild_spec.rb +91 -91
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +220 -220
- data/spec/rake/funnel/tasks/nunit_spec.rb +74 -74
- data/spec/rake/funnel/tasks/paket_spec.rb +140 -142
- data/spec/rake/funnel/tasks/quick_template_spec.rb +62 -62
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +58 -58
- data/spec/rake/funnel/tasks/timing_spec.rb +133 -133
- data/spec/rake/funnel/tasks/zip_spec.rb +50 -50
- data/spec/spec_helper.rb +43 -33
- metadata +2 -3
- data/lib/rake/funnel/support/side_by_side_specs.rb +0 -3
@@ -1,237 +1,237 @@
|
|
1
|
-
require 'open3'
|
2
|
-
|
3
|
-
include Rake::Funnel
|
4
|
-
|
5
|
-
describe Rake::Funnel::Extensions::Shell do
|
6
|
-
before {
|
7
|
-
allow(Open3).to receive(:popen2e).and_yield(nil, stdout_and_stderr, exit)
|
8
|
-
|
9
|
-
allow($stdout).to receive(:puts)
|
10
|
-
allow($stderr).to receive(:puts)
|
11
|
-
allow(Rake).to receive(:rake_output_message)
|
12
|
-
}
|
13
|
-
|
14
|
-
let(:exit) { OpenStruct.new(value: OpenStruct.new(success?: true, exitstatus: 0)) }
|
15
|
-
|
16
|
-
let(:stdout_and_stderr) { StringIO.new("output 1\noutput 2\n") }
|
17
|
-
|
18
|
-
subject { Object.new.extend(described_class) }
|
19
|
-
|
20
|
-
after { stdout_and_stderr.close }
|
21
|
-
|
22
|
-
describe 'command' do
|
23
|
-
it 'should accept simple commands' do
|
24
|
-
arg = 'simple'
|
25
|
-
|
26
|
-
subject.shell(arg)
|
27
|
-
|
28
|
-
expect(Open3).to have_received(:popen2e).with(arg)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should accept commands with arguments as array' do
|
32
|
-
args = %w(simple 1 2)
|
33
|
-
|
34
|
-
subject.shell(args)
|
35
|
-
|
36
|
-
expect(Open3).to have_received(:popen2e).with(*args)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should accept commands with arguments' do
|
40
|
-
subject.shell('1', 2)
|
41
|
-
|
42
|
-
expect(Open3).to have_received(:popen2e).with('1', 2)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should reject nil' do
|
46
|
-
subject.shell(1, nil)
|
47
|
-
|
48
|
-
expect(Open3).to have_received(:popen2e).with(1)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should accept nested arrays' do
|
52
|
-
subject.shell([1, 2, [3]])
|
53
|
-
|
54
|
-
expect(Open3).to have_received(:popen2e).with(1, 2, 3)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should reject nested nils' do
|
58
|
-
subject.shell([1, nil, [3]])
|
59
|
-
|
60
|
-
expect(Open3).to have_received(:popen2e).with(1, 3)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should echo the command' do
|
64
|
-
arg = '1', 2
|
65
|
-
|
66
|
-
subject.shell(arg)
|
67
|
-
|
68
|
-
expect(Rake).to have_received(:rake_output_message).with(arg.join(' '))
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should return nil' do
|
73
|
-
expect(subject.shell('foo')).to be_nil
|
74
|
-
end
|
75
|
-
|
76
|
-
describe 'output redirection' do
|
77
|
-
before { subject.shell('foo') }
|
78
|
-
|
79
|
-
it 'should redirect command output to stdout' do
|
80
|
-
expect($stdout).to have_received(:puts).with(/output 1/)
|
81
|
-
expect($stdout).to have_received(:puts).with(/output 2/)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should colorize lines' do
|
85
|
-
expect($stdout).to have_received(:puts).with('output 1'.green)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'log file' do
|
90
|
-
before {
|
91
|
-
allow(subject).to receive(:mkdir_p)
|
92
|
-
allow(File).to receive(:open)
|
93
|
-
}
|
94
|
-
|
95
|
-
let(:log_file) { nil }
|
96
|
-
|
97
|
-
before { subject.shell('foo', log_file: log_file) }
|
98
|
-
|
99
|
-
context 'no log file' do
|
100
|
-
it 'should not create path to log file' do
|
101
|
-
expect(subject).to_not have_received(:mkdir_p)
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should not write log file' do
|
105
|
-
expect(subject).to_not have_received(:mkdir_p)
|
106
|
-
expect(File).to_not have_received(:open)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'with log file' do
|
111
|
-
let(:log_file) { 'tmp/log.txt' }
|
112
|
-
|
113
|
-
it 'should create path to log file' do
|
114
|
-
expect(subject).to have_received(:mkdir_p).with(File.dirname(log_file))
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'should append to log file' do
|
118
|
-
expect(File).to have_received(:open).with(log_file, 'a').at_least(:once)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe 'error detection' do
|
124
|
-
let(:error_lines) { /error/ }
|
125
|
-
|
126
|
-
before {
|
127
|
-
begin
|
128
|
-
subject.shell('foo', error_lines: error_lines)
|
129
|
-
rescue ExecutionError
|
130
|
-
end
|
131
|
-
}
|
132
|
-
|
133
|
-
context 'no lines indicating errors' do
|
134
|
-
it 'should not log to stderr' do
|
135
|
-
expect($stderr).to_not have_received(:puts)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'lines indicating errors' do
|
140
|
-
let(:stdout_and_stderr) { StringIO.new("output 1\nerror\noutput 2\n") }
|
141
|
-
|
142
|
-
it 'should log to stdout before error' do
|
143
|
-
expect($stdout).to have_received(:puts).with(/output 1/)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'should log to stderr on error' do
|
147
|
-
expect($stderr).to have_received(:puts).with(/error/)
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'should not log to stdout on error' do
|
151
|
-
expect($stdout).to_not have_received(:puts).with(/error/)
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'should colorize error lines' do
|
155
|
-
expect($stderr).to have_received(:puts).with('error'.bold.red)
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'should log to stdout after error' do
|
159
|
-
expect($stdout).to have_received(:puts).with(/output 2/)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe 'callback block' do
|
165
|
-
it 'should yield' do
|
166
|
-
expect { |b| subject.shell('foo', &b) }.to yield_control
|
167
|
-
end
|
168
|
-
|
169
|
-
it 'should yield the success status' do
|
170
|
-
expect { |b| subject.shell('foo', &b) }.to yield_with_args(true,
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'should yield the command' do
|
174
|
-
expect { |b| subject.shell('foo', &b) }.to yield_with_args(
|
175
|
-
end
|
176
|
-
|
177
|
-
it 'should yield the exit code' do
|
178
|
-
expect { |b| subject.shell('foo', &b) }.to yield_with_args(
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'should yield the log' do
|
182
|
-
expect { |b| subject.shell('foo', &b) }.to yield_with_args(
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe 'failure' do
|
187
|
-
context 'error lines logged' do
|
188
|
-
context 'without block' do
|
189
|
-
it 'should fail' do
|
190
|
-
expect { subject.shell('foo', error_lines: /.*/) }.to raise_error(ExecutionError)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context 'with block' do
|
195
|
-
it 'should not fail' do
|
196
|
-
expect { subject.shell('foo', error_lines: /.*/) {} }.not_to raise_error
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'should yield the error' do
|
200
|
-
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false, 'foo', 0, /output/)
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context 'error exit' do
|
206
|
-
let(:exit) { OpenStruct.new(value: OpenStruct.new(success?: false, exitstatus: 1)) }
|
207
|
-
|
208
|
-
context 'without block' do
|
209
|
-
it 'should fail' do
|
210
|
-
expect { subject.shell('foo') }.to raise_error(ExecutionError)
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'should report the exit code' do
|
214
|
-
expect { subject.shell('foo') }.to raise_error { |e| expect(e.exit_code).to eq(exit.value.exitstatus) }
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'should report the command that was run' do
|
218
|
-
expect { subject.shell('foo') }.to raise_error { |e| expect(e.command).to eq('foo') }
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'should report logged lines' do
|
222
|
-
expect { subject.shell('foo') }.to raise_error { |e| expect(e.output).to eq(stdout_and_stderr.string) }
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
context 'with block' do
|
227
|
-
it 'should not fail' do
|
228
|
-
expect { subject.shell('foo') {} }.not_to raise_error
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should yield the error' do
|
232
|
-
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false, 'foo', 1, /output/)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
include Rake::Funnel
|
4
|
+
|
5
|
+
describe Rake::Funnel::Extensions::Shell do
|
6
|
+
before {
|
7
|
+
allow(Open3).to receive(:popen2e).and_yield(nil, stdout_and_stderr, exit)
|
8
|
+
|
9
|
+
allow($stdout).to receive(:puts)
|
10
|
+
allow($stderr).to receive(:puts)
|
11
|
+
allow(Rake).to receive(:rake_output_message)
|
12
|
+
}
|
13
|
+
|
14
|
+
let(:exit) { OpenStruct.new(value: OpenStruct.new(success?: true, exitstatus: 0)) }
|
15
|
+
|
16
|
+
let(:stdout_and_stderr) { StringIO.new("output 1\noutput 2\n") }
|
17
|
+
|
18
|
+
subject { Object.new.extend(described_class) }
|
19
|
+
|
20
|
+
after { stdout_and_stderr.close }
|
21
|
+
|
22
|
+
describe 'command' do
|
23
|
+
it 'should accept simple commands' do
|
24
|
+
arg = 'simple'
|
25
|
+
|
26
|
+
subject.shell(arg)
|
27
|
+
|
28
|
+
expect(Open3).to have_received(:popen2e).with(arg)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should accept commands with arguments as array' do
|
32
|
+
args = %w(simple 1 2)
|
33
|
+
|
34
|
+
subject.shell(args)
|
35
|
+
|
36
|
+
expect(Open3).to have_received(:popen2e).with(*args)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should accept commands with arguments' do
|
40
|
+
subject.shell('1', 2)
|
41
|
+
|
42
|
+
expect(Open3).to have_received(:popen2e).with('1', 2)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should reject nil' do
|
46
|
+
subject.shell(1, nil)
|
47
|
+
|
48
|
+
expect(Open3).to have_received(:popen2e).with(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should accept nested arrays' do
|
52
|
+
subject.shell([1, 2, [3]])
|
53
|
+
|
54
|
+
expect(Open3).to have_received(:popen2e).with(1, 2, 3)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should reject nested nils' do
|
58
|
+
subject.shell([1, nil, [3]])
|
59
|
+
|
60
|
+
expect(Open3).to have_received(:popen2e).with(1, 3)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should echo the command' do
|
64
|
+
arg = '1', 2
|
65
|
+
|
66
|
+
subject.shell(arg)
|
67
|
+
|
68
|
+
expect(Rake).to have_received(:rake_output_message).with(arg.join(' '))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should return nil' do
|
73
|
+
expect(subject.shell('foo')).to be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'output redirection' do
|
77
|
+
before { subject.shell('foo') }
|
78
|
+
|
79
|
+
it 'should redirect command output to stdout' do
|
80
|
+
expect($stdout).to have_received(:puts).with(/output 1/)
|
81
|
+
expect($stdout).to have_received(:puts).with(/output 2/)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should colorize lines' do
|
85
|
+
expect($stdout).to have_received(:puts).with('output 1'.green)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'log file' do
|
90
|
+
before {
|
91
|
+
allow(subject).to receive(:mkdir_p)
|
92
|
+
allow(File).to receive(:open)
|
93
|
+
}
|
94
|
+
|
95
|
+
let(:log_file) { nil }
|
96
|
+
|
97
|
+
before { subject.shell('foo', log_file: log_file) }
|
98
|
+
|
99
|
+
context 'no log file' do
|
100
|
+
it 'should not create path to log file' do
|
101
|
+
expect(subject).to_not have_received(:mkdir_p)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should not write log file' do
|
105
|
+
expect(subject).to_not have_received(:mkdir_p)
|
106
|
+
expect(File).to_not have_received(:open)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'with log file' do
|
111
|
+
let(:log_file) { 'tmp/log.txt' }
|
112
|
+
|
113
|
+
it 'should create path to log file' do
|
114
|
+
expect(subject).to have_received(:mkdir_p).with(File.dirname(log_file))
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should append to log file' do
|
118
|
+
expect(File).to have_received(:open).with(log_file, 'a').at_least(:once)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'error detection' do
|
124
|
+
let(:error_lines) { /error/ }
|
125
|
+
|
126
|
+
before {
|
127
|
+
begin
|
128
|
+
subject.shell('foo', error_lines: error_lines)
|
129
|
+
rescue ExecutionError
|
130
|
+
end
|
131
|
+
}
|
132
|
+
|
133
|
+
context 'no lines indicating errors' do
|
134
|
+
it 'should not log to stderr' do
|
135
|
+
expect($stderr).to_not have_received(:puts)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'lines indicating errors' do
|
140
|
+
let(:stdout_and_stderr) { StringIO.new("output 1\nerror\noutput 2\n") }
|
141
|
+
|
142
|
+
it 'should log to stdout before error' do
|
143
|
+
expect($stdout).to have_received(:puts).with(/output 1/)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should log to stderr on error' do
|
147
|
+
expect($stderr).to have_received(:puts).with(/error/)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should not log to stdout on error' do
|
151
|
+
expect($stdout).to_not have_received(:puts).with(/error/)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should colorize error lines' do
|
155
|
+
expect($stderr).to have_received(:puts).with('error'.bold.red)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should log to stdout after error' do
|
159
|
+
expect($stdout).to have_received(:puts).with(/output 2/)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe 'callback block' do
|
165
|
+
it 'should yield' do
|
166
|
+
expect { |b| subject.shell('foo', &b) }.to yield_control
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should yield the success status' do
|
170
|
+
expect { |b| subject.shell('foo', &b) }.to yield_with_args(true, anything, anything, anything)
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should yield the command' do
|
174
|
+
expect { |b| subject.shell('foo', &b) }.to yield_with_args(anything, 'foo', anything, anything)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should yield the exit code' do
|
178
|
+
expect { |b| subject.shell('foo', &b) }.to yield_with_args(anything, anything, 0, anything)
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should yield the log' do
|
182
|
+
expect { |b| subject.shell('foo', &b) }.to yield_with_args(anything, anything, anything, /output/)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe 'failure' do
|
187
|
+
context 'error lines logged' do
|
188
|
+
context 'without block' do
|
189
|
+
it 'should fail' do
|
190
|
+
expect { subject.shell('foo', error_lines: /.*/) }.to raise_error(ExecutionError)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'with block' do
|
195
|
+
it 'should not fail' do
|
196
|
+
expect { subject.shell('foo', error_lines: /.*/) {} }.not_to raise_error
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'should yield the error' do
|
200
|
+
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false, 'foo', 0, /output/)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'error exit' do
|
206
|
+
let(:exit) { OpenStruct.new(value: OpenStruct.new(success?: false, exitstatus: 1)) }
|
207
|
+
|
208
|
+
context 'without block' do
|
209
|
+
it 'should fail' do
|
210
|
+
expect { subject.shell('foo') }.to raise_error(ExecutionError)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should report the exit code' do
|
214
|
+
expect { subject.shell('foo') }.to raise_error { |e| expect(e.exit_code).to eq(exit.value.exitstatus) }
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should report the command that was run' do
|
218
|
+
expect { subject.shell('foo') }.to raise_error { |e| expect(e.command).to eq('foo') }
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should report logged lines' do
|
222
|
+
expect { subject.shell('foo') }.to raise_error { |e| expect(e.output).to eq(stdout_and_stderr.string) }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'with block' do
|
227
|
+
it 'should not fail' do
|
228
|
+
expect { subject.shell('foo') {} }.not_to raise_error
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should yield the error' do
|
232
|
+
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false, 'foo', 1, /output/)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe Rake::Funnel::Extensions::WindowsPath do
|
2
|
-
it 'should convert forward slash to backslash' do
|
3
|
-
expect('C:\Foo/bar/baz'.to_windows_path).to eq('C:\Foo\bar\baz')
|
4
|
-
end
|
5
|
-
end
|
1
|
+
describe Rake::Funnel::Extensions::WindowsPath do
|
2
|
+
it 'should convert forward slash to backslash' do
|
3
|
+
expect('C:\Foo/bar/baz'.to_windows_path).to eq('C:\Foo\bar\baz')
|
4
|
+
end
|
5
|
+
end
|