rake-funnel 0.18.0 → 0.19.0
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 +1 -0
- data/.simplecov +24 -0
- data/Gemfile +27 -19
- data/README.md +1 -1
- data/lib/rake/funnel/ambiguous_file_error.rb +1 -0
- data/lib/rake/funnel/execution_error.rb +1 -0
- data/lib/rake/funnel/extensions/common_path.rb +5 -4
- data/lib/rake/funnel/extensions/shell.rb +3 -2
- data/lib/rake/funnel/integration/progress_report.rb +3 -2
- data/lib/rake/funnel/integration/sync_output.rb +1 -0
- data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +2 -1
- data/lib/rake/funnel/integration/teamcity/progress_report.rb +1 -1
- data/lib/rake/funnel/integration/teamcity/service_messages.rb +8 -3
- data/lib/rake/funnel/integration/teamcity/teamcity.rb +5 -4
- data/lib/rake/funnel/support/argument_mapper/styles/default.rb +5 -4
- data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +6 -5
- data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +13 -12
- data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +6 -5
- data/lib/rake/funnel/support/assembly_version/from_version_files.rb +2 -1
- data/lib/rake/funnel/support/assembly_version_writer.rb +1 -0
- data/lib/rake/funnel/support/binary_version_reader.rb +14 -7
- data/lib/rake/funnel/support/copier.rb +1 -0
- data/lib/rake/funnel/support/environments/loader.rb +13 -8
- data/lib/rake/funnel/support/internal/finder.rb +2 -1
- data/lib/rake/funnel/support/internal/instantiate_symbol.rb +9 -4
- data/lib/rake/funnel/support/mapper.rb +7 -6
- data/lib/rake/funnel/support/mono.rb +1 -3
- data/lib/rake/funnel/support/msbuild/build_tool.rb +35 -12
- data/lib/rake/funnel/support/msdeploy/registry_patch.rb +14 -17
- data/lib/rake/funnel/support/patch.rb +1 -0
- data/lib/rake/funnel/support/specs_remover.rb +14 -11
- data/lib/rake/funnel/support/template_engine.rb +1 -0
- data/lib/rake/funnel/support/timing/report.rb +11 -10
- data/lib/rake/funnel/support/version_info.rb +8 -9
- data/lib/rake/funnel/support/zipper.rb +1 -0
- data/lib/rake/funnel/tasks/assembly_version.rb +4 -3
- data/lib/rake/funnel/tasks/bin_path.rb +3 -2
- data/lib/rake/funnel/tasks/copy.rb +2 -1
- data/lib/rake/funnel/tasks/environments.rb +13 -9
- data/lib/rake/funnel/tasks/msbuild.rb +4 -6
- data/lib/rake/funnel/tasks/msdeploy.rb +6 -5
- data/lib/rake/funnel/tasks/nunit.rb +3 -2
- data/lib/rake/funnel/tasks/paket.rb +2 -1
- data/lib/rake/funnel/tasks/quick_template.rb +3 -2
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +2 -1
- data/lib/rake/funnel/tasks/timing.rb +7 -6
- data/lib/rake/funnel/tasks/zip.rb +3 -2
- data/lib/rake/funnel/version.rb +1 -1
- data/rake-funnel.gemspec +11 -11
- data/spec/rake/funnel/execution_error_spec.rb +2 -2
- data/spec/rake/funnel/extensions/rexml_spec.rb +5 -2
- data/spec/rake/funnel/extensions/shell_spec.rb +26 -17
- data/spec/rake/funnel/integration/progress_report_spec.rb +32 -36
- data/spec/rake/funnel/integration/sync_output_spec.rb +5 -5
- data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +32 -20
- data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +31 -25
- data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +56 -20
- data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +7 -5
- data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +2 -0
- data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +6 -4
- data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +76 -67
- data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +17 -19
- data/spec/rake/funnel/support/assembly_version_writer_spec.rb +49 -52
- data/spec/rake/funnel/support/binary_version_reader_spec.rb +2 -2
- data/spec/rake/funnel/support/copier_spec.rb +5 -5
- data/spec/rake/funnel/support/environments/loader_spec.rb +32 -32
- data/spec/rake/funnel/support/internal/finder_spec.rb +8 -6
- data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +27 -27
- data/spec/rake/funnel/support/mapper_spec.rb +4 -3
- data/spec/rake/funnel/support/mono_spec.rb +7 -7
- data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +13 -10
- data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +47 -41
- data/spec/rake/funnel/support/patch_spec.rb +11 -11
- data/spec/rake/funnel/support/specs_remover/project/paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover/project/uncompiled-code/paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover/project-specific paket.references/Sample.csproj.paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover/project-specific paket.references/paket.references +3 -3
- data/spec/rake/funnel/support/specs_remover_spec.rb +31 -33
- data/spec/rake/funnel/support/template_engine_spec.rb +6 -3
- data/spec/rake/funnel/support/timing/report_spec.rb +19 -20
- data/spec/rake/funnel/support/trace_spec.rb +6 -6
- data/spec/rake/funnel/support/version_info_spec.rb +8 -6
- data/spec/rake/funnel/support/which_spec.rb +7 -7
- data/spec/rake/funnel/support/zipper_spec.rb +8 -8
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +9 -9
- data/spec/rake/funnel/tasks/bin_path_spec.rb +23 -21
- data/spec/rake/funnel/tasks/copy_spec.rb +10 -10
- data/spec/rake/funnel/tasks/environments_spec.rb +48 -46
- data/spec/rake/funnel/tasks/msbuild_spec.rb +21 -17
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +31 -31
- data/spec/rake/funnel/tasks/nunit_spec.rb +12 -10
- data/spec/rake/funnel/tasks/paket_spec.rb +25 -21
- data/spec/rake/funnel/tasks/quick_template_spec.rb +7 -7
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +12 -12
- data/spec/rake/funnel/tasks/timing_spec.rb +12 -12
- data/spec/rake/funnel/tasks/zip_spec.rb +16 -16
- data/spec/spec_helper.rb +5 -31
- metadata +7 -6
@@ -15,6 +15,7 @@ module Rake
|
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
|
+
|
18
19
|
def setup_ivars(args)
|
19
20
|
@name = args.shift || :package
|
20
21
|
|
@@ -24,11 +25,11 @@ module Rake
|
|
24
25
|
@allow_empty = true
|
25
26
|
end
|
26
27
|
|
27
|
-
def define(args, &task_block)
|
28
|
+
def define(args, &task_block) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
28
29
|
desc 'Zip files' unless Rake.application.last_description
|
29
30
|
|
30
31
|
task(name, *args) do |_, task_args|
|
31
|
-
|
32
|
+
yield(*[self, task_args].slice(0, task_block.arity)) if task_block
|
32
33
|
|
33
34
|
if files.empty? && !allow_empty
|
34
35
|
Rake.rake_output_message('No files to zip')
|
data/lib/rake/funnel/version.rb
CHANGED
data/rake-funnel.gemspec
CHANGED
@@ -2,33 +2,33 @@ lib = File.expand_path('../lib', __FILE__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'rake/funnel/version'
|
4
4
|
|
5
|
-
Gem::Specification.new do |s|
|
5
|
+
Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
|
6
6
|
s.name = 'rake-funnel'
|
7
7
|
s.version = Rake::Funnel::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ['Alexander Groß']
|
10
10
|
s.email = ['agross@therightstuff.de']
|
11
11
|
s.homepage = 'http://grossweber.com'
|
12
|
-
s.license = 'BSD'
|
12
|
+
s.license = 'BSD-3-Clause'
|
13
13
|
s.description = 'A standardized build pipeline'
|
14
|
-
s.summary = 'A build pipeline targeted at .NET projects. Supports environment configuration and makes invoking .NET-related tasks easier.'
|
14
|
+
s.summary = 'A build pipeline targeted at .NET projects. Supports environment configuration and makes invoking .NET-related tasks easier.' # rubocop:disable Metrics/LineLength
|
15
15
|
|
16
16
|
s.required_ruby_version = '>= 2.0.0'
|
17
17
|
|
18
|
-
s.add_dependency 'rake', '>= 10.4', '<
|
18
|
+
s.add_dependency 'rake', '>= 10.4', '< 13'
|
19
19
|
s.add_dependency 'rubyzip', '~> 1.0'
|
20
20
|
s.add_dependency 'smart_colored'
|
21
21
|
s.add_dependency 'configatron', '~> 4.5'
|
22
22
|
|
23
23
|
git = ENV['TEAMCITY_GIT_PATH'] || 'git'
|
24
24
|
files = `"#{git}" ls-files -z`
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
.split("\x0")
|
26
|
+
.reject do |file|
|
27
|
+
file =~ %r{^(config/|tools/|lib/tasks)} ||
|
28
|
+
file =~ /\.git|\.travis|\.ruby-version|\.rubocop/ ||
|
29
|
+
file =~ /(Guard|Rake)file/ ||
|
30
|
+
File.extname(file) == '.cmd'
|
31
|
+
end
|
32
32
|
|
33
33
|
s.files = files
|
34
34
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -38,7 +38,7 @@ describe Rake::Funnel::ExecutionError do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'longer than 10 lines' do
|
41
|
-
let(:output)
|
41
|
+
let(:output) do
|
42
42
|
output = []
|
43
43
|
|
44
44
|
11.times.each do |i|
|
@@ -46,7 +46,7 @@ describe Rake::Funnel::ExecutionError do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
output.join("\n")
|
49
|
-
|
49
|
+
end
|
50
50
|
|
51
51
|
subject { described_class.new(nil, nil, output) }
|
52
52
|
|
@@ -1,12 +1,15 @@
|
|
1
|
+
# rubocop:disable RSpec/FilePath
|
2
|
+
|
1
3
|
describe Rake::Funnel::Extensions::REXML::Functions do
|
2
|
-
let(:xml)
|
4
|
+
let(:xml) do
|
5
|
+
<<EOF
|
3
6
|
<editors xmlns="http://example.com">
|
4
7
|
<editor id="emacs">EMACS</editor>
|
5
8
|
<editor id="vi">VIM</editor>
|
6
9
|
<editor id="notepad">Notepad</editor>
|
7
10
|
</editors>
|
8
11
|
EOF
|
9
|
-
|
12
|
+
end
|
10
13
|
|
11
14
|
subject { REXML::Document.new(xml) }
|
12
15
|
|
@@ -3,13 +3,13 @@ require 'open3'
|
|
3
3
|
include Rake::Funnel
|
4
4
|
|
5
5
|
describe Rake::Funnel::Extensions::Shell do
|
6
|
-
before
|
6
|
+
before do
|
7
7
|
allow(Open3).to receive(:popen2e).and_yield(nil, stdout_and_stderr, exit)
|
8
8
|
|
9
9
|
allow($stdout).to receive(:puts)
|
10
10
|
allow($stderr).to receive(:puts)
|
11
11
|
allow(Rake).to receive(:rake_output_message)
|
12
|
-
|
12
|
+
end
|
13
13
|
|
14
14
|
let(:exit) { OpenStruct.new(value: OpenStruct.new(success?: true, exitstatus: 0)) }
|
15
15
|
|
@@ -87,10 +87,10 @@ describe Rake::Funnel::Extensions::Shell do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
describe 'log file' do
|
90
|
-
before
|
90
|
+
before do
|
91
91
|
allow(subject).to receive(:mkdir_p)
|
92
92
|
allow(File).to receive(:open)
|
93
|
-
|
93
|
+
end
|
94
94
|
|
95
95
|
let(:log_file) { nil }
|
96
96
|
|
@@ -98,12 +98,12 @@ describe Rake::Funnel::Extensions::Shell do
|
|
98
98
|
|
99
99
|
context 'no log file' do
|
100
100
|
it 'should not create path to log file' do
|
101
|
-
expect(subject).
|
101
|
+
expect(subject).not_to have_received(:mkdir_p)
|
102
102
|
end
|
103
103
|
|
104
104
|
it 'should not write log file' do
|
105
|
-
expect(subject).
|
106
|
-
expect(File).
|
105
|
+
expect(subject).not_to have_received(:mkdir_p)
|
106
|
+
expect(File).not_to have_received(:open)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -123,16 +123,16 @@ describe Rake::Funnel::Extensions::Shell do
|
|
123
123
|
describe 'error detection' do
|
124
124
|
let(:error_lines) { /error/ }
|
125
125
|
|
126
|
-
before
|
126
|
+
before do
|
127
127
|
begin
|
128
128
|
subject.shell('foo', error_lines: error_lines)
|
129
|
-
rescue ExecutionError
|
129
|
+
rescue ExecutionError # rubocop:disable Lint/HandleExceptions
|
130
130
|
end
|
131
|
-
|
131
|
+
end
|
132
132
|
|
133
133
|
context 'no lines indicating errors' do
|
134
134
|
it 'should not log to stderr' do
|
135
|
-
expect($stderr).
|
135
|
+
expect($stderr).not_to have_received(:puts)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -148,7 +148,7 @@ describe Rake::Funnel::Extensions::Shell do
|
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'should not log to stdout on error' do
|
151
|
-
expect($stdout).
|
151
|
+
expect($stdout).not_to have_received(:puts).with(/error/)
|
152
152
|
end
|
153
153
|
|
154
154
|
it 'should colorize error lines' do
|
@@ -205,7 +205,10 @@ describe Rake::Funnel::Extensions::Shell do
|
|
205
205
|
end
|
206
206
|
|
207
207
|
it 'should yield the error' do
|
208
|
-
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false,
|
208
|
+
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false,
|
209
|
+
'foo',
|
210
|
+
0,
|
211
|
+
/output/)
|
209
212
|
end
|
210
213
|
end
|
211
214
|
end
|
@@ -219,15 +222,18 @@ describe Rake::Funnel::Extensions::Shell do
|
|
219
222
|
end
|
220
223
|
|
221
224
|
it 'should report the exit code' do
|
222
|
-
expect { subject.shell('foo') }
|
225
|
+
expect { subject.shell('foo') }
|
226
|
+
.to(raise_error { |e| expect(e.exit_code).to eq(exit.value.exitstatus) })
|
223
227
|
end
|
224
228
|
|
225
229
|
it 'should report the command that was run' do
|
226
|
-
expect { subject.shell('foo') }
|
230
|
+
expect { subject.shell('foo') }
|
231
|
+
.to(raise_error { |e| expect(e.command).to eq('foo') })
|
227
232
|
end
|
228
233
|
|
229
234
|
it 'should report logged lines' do
|
230
|
-
expect { subject.shell('foo') }
|
235
|
+
expect { subject.shell('foo') }
|
236
|
+
.to(raise_error { |e| expect(e.output).to eq(stdout_and_stderr.string) })
|
231
237
|
end
|
232
238
|
end
|
233
239
|
|
@@ -237,7 +243,10 @@ describe Rake::Funnel::Extensions::Shell do
|
|
237
243
|
end
|
238
244
|
|
239
245
|
it 'should yield the error' do
|
240
|
-
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false,
|
246
|
+
expect { |b| subject.shell('foo', error_lines: /.*/, &b) }.to yield_with_args(false,
|
247
|
+
'foo',
|
248
|
+
1,
|
249
|
+
/output/)
|
241
250
|
end
|
242
251
|
end
|
243
252
|
end
|
@@ -6,27 +6,27 @@ describe Rake::Funnel::Integration::ProgressReport do
|
|
6
6
|
|
7
7
|
let(:teamcity_running?) { false }
|
8
8
|
|
9
|
-
before
|
9
|
+
before do
|
10
10
|
allow($stdout).to receive(:puts)
|
11
11
|
allow(TeamCity).to receive(:running?).and_return(teamcity_running?)
|
12
12
|
|
13
13
|
Task.clear
|
14
|
-
|
14
|
+
end
|
15
15
|
|
16
|
-
after
|
16
|
+
after do
|
17
17
|
subject.disable!
|
18
|
-
|
18
|
+
end
|
19
19
|
|
20
20
|
describe 'defaults' do
|
21
|
-
subject!
|
21
|
+
subject! do
|
22
22
|
described_class.new
|
23
|
-
|
23
|
+
end
|
24
24
|
|
25
|
-
before
|
25
|
+
before do
|
26
26
|
task :task
|
27
27
|
|
28
28
|
Task[:task].invoke
|
29
|
-
|
29
|
+
end
|
30
30
|
|
31
31
|
context 'not on TeamCity' do
|
32
32
|
it 'should write colored task name in square brackets' do
|
@@ -38,57 +38,53 @@ describe Rake::Funnel::Integration::ProgressReport do
|
|
38
38
|
let(:teamcity_running?) { true }
|
39
39
|
|
40
40
|
it 'should not write task name since it would clutter the output' do
|
41
|
-
expect($stdout).
|
41
|
+
expect($stdout).not_to have_received(:puts).with(/task/)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'when progess report was disabled' do
|
47
|
-
subject
|
47
|
+
subject do
|
48
48
|
described_class.new
|
49
|
-
|
49
|
+
end
|
50
50
|
|
51
|
-
before
|
51
|
+
before do
|
52
52
|
subject.disable!
|
53
53
|
|
54
54
|
task :task
|
55
55
|
|
56
56
|
Task[:task].invoke
|
57
|
-
|
57
|
+
end
|
58
58
|
|
59
59
|
it 'should not write' do
|
60
|
-
expect($stdout).
|
60
|
+
expect($stdout).not_to have_received(:puts).with("\n[task]")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe 'custom event handlers' do
|
65
65
|
let(:receiver) { double.as_null_object }
|
66
66
|
|
67
|
-
subject!
|
67
|
+
subject! do
|
68
68
|
described_class.new do |r|
|
69
69
|
r.task_starting do |task, args|
|
70
|
-
receiver.task_starting(
|
71
|
-
|
72
|
-
args: args
|
73
|
-
})
|
70
|
+
receiver.task_starting(task: task,
|
71
|
+
args: args)
|
74
72
|
end
|
75
73
|
|
76
74
|
r.task_finished do |task, args, error|
|
77
|
-
receiver.task_finished(
|
78
|
-
|
79
|
-
|
80
|
-
error: error
|
81
|
-
})
|
75
|
+
receiver.task_finished(task: task,
|
76
|
+
args: args,
|
77
|
+
error: error)
|
82
78
|
end
|
83
79
|
end
|
84
|
-
|
80
|
+
end
|
85
81
|
|
86
82
|
context 'when task succeeds' do
|
87
|
-
before
|
83
|
+
before do
|
88
84
|
task :task
|
89
85
|
|
90
86
|
Task[:task].invoke
|
91
|
-
|
87
|
+
end
|
92
88
|
|
93
89
|
describe 'starting handler' do
|
94
90
|
it 'should run' do
|
@@ -96,11 +92,11 @@ describe Rake::Funnel::Integration::ProgressReport do
|
|
96
92
|
end
|
97
93
|
|
98
94
|
it 'should receive task' do
|
99
|
-
expect(receiver).to have_received(:task_starting).with(hash_including(
|
95
|
+
expect(receiver).to have_received(:task_starting).with(hash_including(task: kind_of(Task)))
|
100
96
|
end
|
101
97
|
|
102
98
|
it 'should receive task arguments' do
|
103
|
-
expect(receiver).to have_received(:task_starting).with(hash_including(
|
99
|
+
expect(receiver).to have_received(:task_starting).with(hash_including(args: kind_of(TaskArguments)))
|
104
100
|
end
|
105
101
|
end
|
106
102
|
|
@@ -110,15 +106,15 @@ describe Rake::Funnel::Integration::ProgressReport do
|
|
110
106
|
end
|
111
107
|
|
112
108
|
it 'should receive task' do
|
113
|
-
expect(receiver).to have_received(:task_finished).with(hash_including(
|
109
|
+
expect(receiver).to have_received(:task_finished).with(hash_including(task: kind_of(Task)))
|
114
110
|
end
|
115
111
|
|
116
112
|
it 'should receive task arguments' do
|
117
|
-
expect(receiver).to have_received(:task_finished).with(hash_including(
|
113
|
+
expect(receiver).to have_received(:task_finished).with(hash_including(args: kind_of(TaskArguments)))
|
118
114
|
end
|
119
115
|
|
120
116
|
it 'should not receive error' do
|
121
|
-
expect(receiver).to have_received(:task_finished).with(hash_including(
|
117
|
+
expect(receiver).to have_received(:task_finished).with(hash_including(error: nil))
|
122
118
|
end
|
123
119
|
end
|
124
120
|
end
|
@@ -128,20 +124,20 @@ describe Rake::Funnel::Integration::ProgressReport do
|
|
128
124
|
|
129
125
|
let(:error) { SpecificError.new('task error') }
|
130
126
|
|
131
|
-
before
|
127
|
+
before do
|
132
128
|
task :task do
|
133
129
|
raise error
|
134
130
|
end
|
135
131
|
|
136
132
|
begin
|
137
133
|
Task[:task].invoke
|
138
|
-
rescue SpecificError
|
134
|
+
rescue SpecificError # rubocop:disable Lint/HandleExceptions
|
139
135
|
end
|
140
|
-
|
136
|
+
end
|
141
137
|
|
142
138
|
describe 'finished handler' do
|
143
139
|
it 'should receive error' do
|
144
|
-
expect(receiver).to have_received(:task_finished).with(hash_including(
|
140
|
+
expect(receiver).to have_received(:task_finished).with(hash_including(error: error))
|
145
141
|
end
|
146
142
|
end
|
147
143
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
describe Rake::Funnel::Integration::SyncOutput do
|
2
2
|
context 'stream supports sync mode' do
|
3
|
-
before
|
3
|
+
before do
|
4
4
|
allow($stdout).to receive(:sync=)
|
5
5
|
allow($stderr).to receive(:sync=)
|
6
6
|
|
7
7
|
expect(subject).to be
|
8
|
-
|
8
|
+
end
|
9
9
|
|
10
10
|
it 'should immediately flush $stdout' do
|
11
11
|
expect($stdout).to have_received(:sync=).with(true)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should immediately flush $stderr' do
|
15
|
-
expect($
|
15
|
+
expect($stderr).to have_received(:sync=).with(true)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'stream does not support sync mode' do
|
20
|
-
before
|
20
|
+
before do
|
21
21
|
allow($stdout).to receive(:sync=).and_raise('$stdout.sync not supported')
|
22
22
|
allow($stderr).to receive(:sync=).and_raise('$stderr.sync not supported')
|
23
23
|
|
24
24
|
allow(Rake).to receive(:rake_output_message)
|
25
25
|
|
26
26
|
expect(subject).to be
|
27
|
-
|
27
|
+
end
|
28
28
|
|
29
29
|
it 'should log the error for $stdout' do
|
30
30
|
expect(Rake).to have_received(:rake_output_message).with(/Failed.*\$stdout/)
|
@@ -1,33 +1,35 @@
|
|
1
|
+
# rubocop:disable RSpec/FilePath
|
2
|
+
|
1
3
|
include Rake::Funnel::Support
|
2
4
|
|
3
5
|
describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
4
|
-
before
|
6
|
+
before do
|
5
7
|
allow(ENV).to receive(:[]).with(described_class::ENV_VAR).and_return(env_var)
|
6
8
|
allow(Which).to receive(:which).and_return(which)
|
7
9
|
allow(Dir).to receive(:glob).and_return([])
|
8
10
|
allow(RakeFileUtils).to receive(:mkdir_p)
|
9
11
|
allow(Rake).to receive(:rake_output_message)
|
10
|
-
|
12
|
+
end
|
11
13
|
|
12
|
-
before
|
14
|
+
before do
|
13
15
|
allow(BinaryVersionReader).to receive(:read_from).with(which).and_return(nunit_version)
|
14
|
-
|
16
|
+
end
|
15
17
|
|
16
18
|
describe 'success' do
|
17
19
|
let(:env_var) { '/path/to/nunit plugins/nunit' }
|
18
20
|
let(:addin_dlls) { [env_var + 'addin.dll'] }
|
19
21
|
let(:which) { 'path/to/nunit-console.exe' }
|
20
|
-
let(:nunit_version) { VersionInfo.new(
|
22
|
+
let(:nunit_version) { VersionInfo.new(file_version: '1.2.3.4') }
|
21
23
|
let(:plugin_version) { nunit_version.file_version.split('.').take(3).join('.') }
|
22
24
|
|
23
|
-
before
|
25
|
+
before do
|
24
26
|
allow(Dir).to receive(:glob).and_return(addin_dlls)
|
25
27
|
allow(RakeFileUtils).to receive(:cp)
|
26
|
-
|
28
|
+
end
|
27
29
|
|
28
|
-
before
|
30
|
+
before do
|
29
31
|
described_class.setup('nunit-console.exe')
|
30
|
-
|
32
|
+
end
|
31
33
|
|
32
34
|
it 'should create addin directory' do
|
33
35
|
expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(File.dirname(which), 'addins'))
|
@@ -38,18 +40,24 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
38
40
|
end
|
39
41
|
|
40
42
|
it 'should copy the addin from TeamCity to NUnit' do
|
41
|
-
expect(RakeFileUtils).to
|
43
|
+
expect(RakeFileUtils).to \
|
44
|
+
have_received(:cp).with(addin_dlls,
|
45
|
+
File.join(File.dirname(which), 'addins'),
|
46
|
+
preserve: true)
|
42
47
|
end
|
43
48
|
|
44
49
|
it 'should report that the addin is installed' do
|
45
|
-
expect(Rake).to
|
50
|
+
expect(Rake).to \
|
51
|
+
have_received(:rake_output_message)
|
52
|
+
.with("Installing TeamCity NUnit addin for version #{plugin_version} in #{which}")
|
46
53
|
end
|
47
54
|
|
48
|
-
context 'Windows-style path in environment variable',
|
55
|
+
context 'Windows-style path in environment variable',
|
56
|
+
skip: ('Windows Registry not available' unless defined?(::Win32::Registry)) do
|
49
57
|
let(:env_var) { 'C:\path\to\nunit plugins\nunit-' }
|
50
58
|
|
51
59
|
it 'should convert path to Ruby-style' do
|
52
|
-
expect(Dir).to have_received(:glob).with(%r
|
60
|
+
expect(Dir).to have_received(:glob).with(%r{^C:/path/to/nunit plugins/nunit-})
|
53
61
|
end
|
54
62
|
end
|
55
63
|
end
|
@@ -59,15 +67,15 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
59
67
|
let(:which) { nil }
|
60
68
|
let(:nunit_version) { VersionInfo.new }
|
61
69
|
|
62
|
-
before
|
70
|
+
before do
|
63
71
|
described_class.setup('nunit-console.exe')
|
64
|
-
|
72
|
+
end
|
65
73
|
|
66
74
|
context 'TeamCity plugin path not in environment' do
|
67
75
|
let(:env_var) { nil }
|
68
76
|
|
69
77
|
it 'should skip reading the version' do
|
70
|
-
expect(BinaryVersionReader).
|
78
|
+
expect(BinaryVersionReader).not_to have_received(:read_from)
|
71
79
|
end
|
72
80
|
end
|
73
81
|
|
@@ -76,7 +84,7 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
76
84
|
let(:which) { nil }
|
77
85
|
|
78
86
|
it 'should skip reading the version' do
|
79
|
-
expect(BinaryVersionReader).
|
87
|
+
expect(BinaryVersionReader).not_to have_received(:read_from)
|
80
88
|
end
|
81
89
|
end
|
82
90
|
|
@@ -85,7 +93,9 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
85
93
|
let(:which) { 'path/to/nunit-console.exe' }
|
86
94
|
|
87
95
|
it 'should report that the version could not be read' do
|
88
|
-
expect(Rake).to
|
96
|
+
expect(Rake).to \
|
97
|
+
have_received(:rake_output_message)
|
98
|
+
.with("Could read version from NUnit executable in #{which}")
|
89
99
|
end
|
90
100
|
|
91
101
|
it 'should skip' do
|
@@ -96,10 +106,12 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
96
106
|
context 'plugin for NUnit version not available' do
|
97
107
|
let(:env_var) { '/path/to/nunit plugins/nunit' }
|
98
108
|
let(:which) { 'path/to/nunit-console.exe' }
|
99
|
-
let(:nunit_version) { VersionInfo.new(
|
109
|
+
let(:nunit_version) { VersionInfo.new(file_version: '1.2.3.4') }
|
100
110
|
|
101
111
|
it 'should report that the addin version is not available' do
|
102
|
-
expect(Rake).to
|
112
|
+
expect(Rake).to \
|
113
|
+
have_received(:rake_output_message)
|
114
|
+
.with(/Could not find TeamCity NUnit addin for version 1\.2\.3 in .*#{env_var}$/)
|
103
115
|
end
|
104
116
|
|
105
117
|
it 'should skip' do
|