rake-funnel 0.21.2 → 0.22.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.
Files changed (30) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5 -0
  3. data/lib/rake/funnel/integration/progress_report.rb +1 -1
  4. data/lib/rake/funnel/integration/sync_output.rb +1 -1
  5. data/lib/rake/funnel/integration/teamcity/progress_report.rb +2 -6
  6. data/lib/rake/funnel/support/msbuild/build_tool.rb +36 -13
  7. data/lib/rake/funnel/tasks/msbuild.rb +1 -1
  8. data/lib/rake/funnel/version.rb +1 -1
  9. data/rake-funnel.gemspec +3 -2
  10. data/spec/rake/funnel/extensions/common_path_spec.rb +3 -2
  11. data/spec/rake/funnel/extensions/rexml_spec.rb +1 -3
  12. data/spec/rake/funnel/integration/sync_output_spec.rb +4 -4
  13. data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +1 -3
  14. data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +9 -11
  15. data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +1 -3
  16. data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +1 -3
  17. data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +1 -3
  18. data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +1 -3
  19. data/spec/rake/funnel/support/assembly_version_writer_spec.rb +1 -5
  20. data/spec/rake/funnel/support/internal/finder_spec.rb +1 -3
  21. data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +1 -3
  22. data/spec/rake/funnel/support/mapper_spec.rb +3 -3
  23. data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +126 -37
  24. data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +1 -3
  25. data/spec/rake/funnel/support/timing/report_spec.rb +6 -6
  26. data/spec/rake/funnel/tasks/msbuild_spec.rb +1 -3
  27. data/spec/rake/funnel/tasks/msdeploy_spec.rb +1 -3
  28. data/spec/rake/funnel/tasks/nunit_spec.rb +1 -3
  29. data/spec/rake/funnel/tasks/timing_spec.rb +5 -5
  30. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 38b45b7ac59fc6d322fc922dc101998e82127b90
4
- data.tar.gz: 70934ba3d057a57f1463850f458e6d496c68bef2
2
+ SHA256:
3
+ metadata.gz: ba6054ccf746282d7b18f44405a4a1f24e3f2dabc36dfc1ce5b8a5fd90bbc9b1
4
+ data.tar.gz: ad1ba7b758b76396150182661dcf4936b133f3b52007e2ceb582dd0339e9af7c
5
5
  SHA512:
6
- metadata.gz: 4d1c427c3189d23be7a625bb9f8149283d21068b9811e4341df0dd2ab49ae52551af021a2d5668ce767a91ac622b585c91d13dfccfffa52cc56ba186f4831b9c
7
- data.tar.gz: 1df053f403858d78d261b80abd2d6bf0dfdc4ec48278245f87ff919d056ee777e4b934a5aa4d026d4170dde4e740bb2662c17b23b8ad1376309f722e3f173386
6
+ metadata.gz: 51eaeeef60d39328f4a0b6ef35b66560b5d5f0b8d61291282aae964bffcd4043d22432dd261d5879a8324535058f2284fc680b7b852277d5dc761f0abb91213a
7
+ data.tar.gz: afe151343b40f3c2510a575140c4a42df399196d58e98f6ef4e88c199ea6b1e7138575cc43e2fa962299b4abfaf5994791737926a74f2d5f59cec9d74e6b066f
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # 0.22.0 / 2018-05-05
2
+
3
+ * [FEATURE] Support [vswhere](https://github.com/Microsoft/vswhere) to locate
4
+ MSBuild. It's advised to install vswhere as a NuGet package and add it to the
5
+ `PATH`. You can use `Rake::Funnel::Tasks::BinPath` for that.
@@ -46,7 +46,7 @@ module Rake
46
46
  error = nil
47
47
  begin
48
48
  old_execute.bind(self).call(args)
49
- rescue => e # rubocop:disable Lint/RescueWithoutErrorClass
49
+ rescue => e # rubocop:disable Style/RescueStandardError
50
50
  error = e
51
51
  ensure
52
52
  context.finished.call(self, args, error) if context.finished
@@ -11,7 +11,7 @@ module Rake
11
11
 
12
12
  def sync(stream)
13
13
  stream.sync = true
14
- rescue => e # rubocop:disable Lint/RescueWithoutErrorClass
14
+ rescue => e # rubocop:disable Style/RescueStandardError
15
15
  Rake.rake_output_message "Failed to set up sync output #{e}"
16
16
  end
17
17
  end
@@ -12,17 +12,13 @@ module Rake
12
12
  task_starting do |task, _args|
13
13
  next unless TeamCity.running?
14
14
 
15
- unless TeamCity.rake_runner?
16
- ServiceMessages.block_opened(name: task.name)
17
- end
15
+ ServiceMessages.block_opened(name: task.name) unless TeamCity.rake_runner?
18
16
  end
19
17
 
20
18
  task_finished do |task, _args, error|
21
19
  next unless TeamCity.running?
22
20
 
23
- if error.respond_to?(:inner_exception)
24
- error = error.inner_exception
25
- end
21
+ error = error.inner_exception if error.respond_to?(:inner_exception)
26
22
 
27
23
  ServiceMessages.build_problem(description: error.message[0..4000 - 1]) if error
28
24
 
@@ -7,41 +7,64 @@ module Rake
7
7
  class BuildTool
8
8
  class << self
9
9
  def find
10
- mono_build || from_registry.compact.first
10
+ vswhere ||
11
+ from_registry ||
12
+ mono ||
13
+ raise('No compatible MSBuild build tool was found')
11
14
  end
12
15
 
13
16
  private
14
17
 
15
- def mono_build
16
- return nil if Rake::Win32.windows?
17
-
18
- begin
19
- out, status = Open3.capture2('mono', '--version')
20
- raise "Could not determine mono version: #{status}" unless status.success?
21
- rescue Errno::ENOENT
22
- raise 'mono is not installed'
18
+ def mono
19
+ out, status = Open3.capture2('mono', '--version')
20
+ unless status.success?
21
+ warn "Could not determine mono version: #{status}"
22
+ return nil
23
23
  end
24
24
 
25
25
  return 'msbuild'.freeze if out[/^Mono JIT compiler version ([\d\.]+)/, 1] >= '5.0'
26
26
 
27
27
  'xbuild'.freeze
28
+ rescue Errno::ENOENT
29
+ nil
30
+ end
31
+
32
+ def vswhere # rubocop:disable Metrics/MethodLength
33
+ # -products * is required.
34
+ # https://github.com/Microsoft/vswhere/issues/61#issuecomment-298691077
35
+ args = %w(vswhere.exe
36
+ -products *
37
+ -latest
38
+ -requires Microsoft.Component.MSBuild
39
+ -property installationPath)
40
+
41
+ path, status = Open3.capture2(*args)
42
+ unless status.success?
43
+ warn "vswhere failed: #{status}"
44
+ return nil
45
+ end
46
+
47
+ Dir[File.join(Rake::Win32.normalize(path.strip),
48
+ 'MSBuild/*/Bin/MSBuild.exe')]
49
+ .find { |e| File.file?(e) }
50
+ rescue Errno::ENOENT
51
+ nil
28
52
  end
29
53
 
30
54
  KEY = 'SOFTWARE\Microsoft\MSBuild\ToolsVersions'.freeze
55
+ REGISTRY_VERSIONS = %w(14.0 12.0 4.0 3.5 2.0).freeze
31
56
 
32
57
  def from_registry
33
58
  return nil unless require_registry
34
59
 
35
- versions.map do |version|
60
+ candidates = REGISTRY_VERSIONS.map do |version|
36
61
  version_key(version) do |reg|
37
62
  candidate = File.join(reg['MSBuildToolsPath'] || '', 'msbuild.exe')
38
63
  next candidate if File.exist?(candidate)
39
64
  end
40
65
  end
41
- end
42
66
 
43
- def versions
44
- %w(14.0 12.0 4.0 3.5 2.0)
67
+ candidates.compact.first
45
68
  end
46
69
 
47
70
  def require_registry
@@ -26,7 +26,7 @@ module Rake
26
26
  @name = args.shift || :compile
27
27
 
28
28
  @msbuild = nil
29
- @msbuild_finder = ->() { BuildTool.find }
29
+ @msbuild_finder = -> { BuildTool.find }
30
30
  @args = {}
31
31
  @search_pattern = %w(**/*.sln)
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Funnel
3
- VERSION = '0.21.2'.freeze
3
+ VERSION = '0.22.0'.freeze
4
4
  end
5
5
  end
data/rake-funnel.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'rake/funnel/version'
4
4
 
@@ -13,7 +13,8 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
13
13
  s.description = 'A standardized build pipeline'
14
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
- s.required_ruby_version = '>= 2.0.0'
16
+ # We support Ruby 2.0 whereas rubocop does not.
17
+ s.required_ruby_version = '>= 2.0.0' # rubocop:disable Gemspec/RequiredRubyVersion
17
18
 
18
19
  s.add_dependency 'configatron', '~> 4.5'
19
20
  s.add_dependency 'rake', '>= 10.4', '< 13'
@@ -1,7 +1,7 @@
1
1
  describe Rake::Funnel::Extensions::CommonPath do
2
2
  describe 'Manual debugging test case' do
3
3
  it 'should work' do
4
- expect(%w(/common/one /com/two).common_path).to be
4
+ expect(%w(/common/one /com/two).common_path).to be_truthy
5
5
 
6
6
  skip('for manual testing only')
7
7
  end
@@ -12,7 +12,8 @@ describe Rake::Funnel::Extensions::CommonPath do
12
12
  input = FileList[File.join(File.dirname(__FILE__), '**/*')]
13
13
  duped = input.dup
14
14
 
15
- expect(input.common_path).to be
15
+ expect(input.common_path).to be_truthy
16
+
16
17
  expect(input).to match_array(duped)
17
18
  end
18
19
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Extensions::REXML::Functions do
1
+ describe Rake::Funnel::Extensions::REXML::Functions do # rubocop:disable RSpec/FilePath
4
2
  let(:xml) do
5
3
  <<XML
6
4
  <editors xmlns="http://example.com">
@@ -3,10 +3,10 @@ describe Rake::Funnel::Integration::SyncOutput do
3
3
  before do
4
4
  allow($stdout).to receive(:sync=)
5
5
  allow($stderr).to receive(:sync=)
6
-
7
- expect(subject).to be # rubocop:disable RSpec/ExpectInHook
8
6
  end
9
7
 
8
+ subject! { described_class.new }
9
+
10
10
  it 'should immediately flush $stdout' do
11
11
  expect($stdout).to have_received(:sync=).with(true)
12
12
  end
@@ -22,10 +22,10 @@ describe Rake::Funnel::Integration::SyncOutput do
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
-
26
- expect(subject).to be # rubocop:disable RSpec/ExpectInHook
27
25
  end
28
26
 
27
+ subject! { described_class.new }
28
+
29
29
  it 'should log the error for $stdout' do
30
30
  expect(Rake).to have_received(:rake_output_message).with(/Failed.*\$stdout/)
31
31
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
1
+ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do # rubocop:disable RSpec/FilePath
4
2
  before do
5
3
  allow(ENV).to receive(:[]).with(described_class::ENV_VAR).and_return(env_var)
6
4
  allow(Rake::Funnel::Support::Which).to receive(:which).and_return(which)
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Integration::TeamCity::ProgressReport do
1
+ describe Rake::Funnel::Integration::TeamCity::ProgressReport do # rubocop:disable RSpec/FilePath
4
2
  include Rake::DSL
5
3
 
6
4
  let(:teamcity_running?) { false }
@@ -26,7 +24,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
26
24
  subject.disable!
27
25
  end
28
26
 
29
- shared_examples :block_report do
27
+ shared_examples 'block report' do
30
28
  it 'should write block start' do
31
29
  expect(Rake::Funnel::Integration::TeamCity::ServiceMessages).to \
32
30
  have_received(:block_opened).with(name: 'task')
@@ -38,7 +36,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
38
36
  end
39
37
  end
40
38
 
41
- shared_examples :no_block_report do
39
+ shared_examples 'no block report' do
42
40
  it 'should not write block start' do
43
41
  expect(Rake::Funnel::Integration::TeamCity::ServiceMessages).not_to \
44
42
  have_received(:block_opened)
@@ -63,20 +61,20 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
63
61
  end
64
62
 
65
63
  context 'not on TeamCity' do
66
- it_behaves_like :no_block_report
64
+ it_behaves_like 'no block report'
67
65
  end
68
66
 
69
67
  context 'on TeamCity' do
70
68
  let(:teamcity_running?) { true }
71
69
 
72
70
  context 'without rake runner' do
73
- it_behaves_like :block_report
71
+ it_behaves_like 'block report'
74
72
  end
75
73
 
76
74
  context 'with rake runner' do
77
75
  let(:teamcity_rake_runner?) { true }
78
76
 
79
- it_behaves_like :no_block_report
77
+ it_behaves_like 'no block report'
80
78
  end
81
79
  end
82
80
  end
@@ -111,7 +109,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
111
109
  end
112
110
 
113
111
  context 'not on TeamCity' do
114
- it_behaves_like :no_block_report
112
+ it_behaves_like 'no block report'
115
113
 
116
114
  it 'should not swallow the error' do
117
115
  expect(@raised_error).to be_a_kind_of(SpecificError) # rubocop:disable RSpec/InstanceVariable
@@ -141,7 +139,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
141
139
  end
142
140
 
143
141
  context 'without rake runner' do
144
- it_behaves_like :block_report
142
+ it_behaves_like 'block report'
145
143
 
146
144
  it 'should report the error as a build problem' do
147
145
  expect(Rake::Funnel::Integration::TeamCity::ServiceMessages).to \
@@ -160,7 +158,7 @@ describe Rake::Funnel::Integration::TeamCity::ProgressReport do
160
158
  have_received(:build_problem).with(description: 'inner message')
161
159
  end
162
160
 
163
- it_behaves_like :no_block_report
161
+ it_behaves_like 'no block report'
164
162
  end
165
163
  end
166
164
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Integration::TeamCity::ServiceMessages do
1
+ describe Rake::Funnel::Integration::TeamCity::ServiceMessages do # rubocop:disable RSpec/FilePath
4
2
  before do
5
3
  allow(Rake::Funnel::Integration::TeamCity).to receive(:running?).and_return(teamcity_running?)
6
4
  allow($stdout).to receive(:puts)
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Integration::TeamCity do
1
+ describe Rake::Funnel::Integration::TeamCity do # rubocop:disable RSpec/FilePath
4
2
  describe 'runner detection' do
5
3
  before do
6
4
  allow(ENV).to receive(:include?).with(described_class::PROJECT_ENV_VAR).and_return(teamcity_running?)
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Support::Mapper::Styles::MSDeploy do
1
+ describe Rake::Funnel::Support::Mapper::Styles::MSDeploy do # rubocop:disable RSpec/FilePath
4
2
  subject { Rake::Funnel::Support::Mapper.new(:MSDeploy) }
5
3
 
6
4
  describe 'no arguments' do
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Support::Mapper::Styles::NUnit do
1
+ describe Rake::Funnel::Support::Mapper::Styles::NUnit do # rubocop:disable RSpec/FilePath
4
2
  subject { Rake::Funnel::Support::Mapper.new(:NUnit) }
5
3
 
6
4
  describe 'prefix' do
@@ -43,12 +43,8 @@ describe Rake::Funnel::Support::AssemblyVersionWriter do
43
43
  ]
44
44
  end
45
45
 
46
- subject do
47
- described_class.new(source)
48
- end
49
-
50
46
  it 'should succeed' do
51
- expect(subject).to be
47
+ described_class.new(source)
52
48
  end
53
49
  end
54
50
  end
@@ -1,8 +1,6 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
1
  require 'tmpdir'
4
2
 
5
- describe Rake::Funnel::Support::Finder do
3
+ describe Rake::Funnel::Support::Finder do # rubocop:disable RSpec/FilePath
6
4
  let(:pattern) { %W(#{temp_dir}/**/*.sln #{temp_dir}/**/*.??proj) }
7
5
  let(:generate) { [] }
8
6
  let(:temp_dir) { Dir.mktmpdir }
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Support::InstantiateSymbol do
1
+ describe Rake::Funnel::Support::InstantiateSymbol do # rubocop:disable RSpec/FilePath
4
2
  module Creatable
5
3
  class One
6
4
  end
@@ -17,7 +17,7 @@ describe Rake::Funnel::Support::Mapper do
17
17
  end
18
18
 
19
19
  class CustomMapper
20
- def generate_from(_)
20
+ def generate_from(_ignored)
21
21
  [
22
22
  ['-', 'switch'],
23
23
  ['-', :some_switch],
@@ -40,7 +40,7 @@ describe Rake::Funnel::Support::Mapper do
40
40
  describe 'mapper style' do
41
41
  context 'default mapper' do
42
42
  it 'should use default mapper' do
43
- expect(described_class.new).to be
43
+ expect(described_class.new).to be_kind_of(described_class)
44
44
  end
45
45
  end
46
46
 
@@ -59,7 +59,7 @@ describe Rake::Funnel::Support::Mapper do
59
59
 
60
60
  context 'custom mapper' do
61
61
  it 'should take custom mapper instance' do
62
- expect(described_class.new(CustomMapper.new)).to be
62
+ expect(described_class.new(CustomMapper.new)).to be_kind_of(described_class)
63
63
  end
64
64
  end
65
65
  end
@@ -1,75 +1,155 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
1
  require 'ostruct'
4
2
 
5
- describe Rake::Funnel::Support::MSBuild::BuildTool do
6
- before do
7
- allow(Rake::Win32).to receive(:windows?).and_return(windows?)
8
- end
3
+ describe Rake::Funnel::Support::MSBuild::BuildTool do # rubocop:disable RSpec/FilePath
4
+ context 'vswhere' do
5
+ let(:vswhere_args) do
6
+ %w(vswhere.exe -products * -latest -requires Microsoft.Component.MSBuild -property installationPath)
7
+ end
8
+
9
+ before do
10
+ allow(described_class).to receive(:require).with('win32/registry').and_raise(LoadError)
11
+ allow(Open3).to receive(:capture2).with('mono', any_args).and_raise(Errno::ENOENT)
12
+ end
13
+
14
+ context 'not installed' do
15
+ before do
16
+ allow(Open3).to receive(:capture2).with(*vswhere_args).and_raise(Errno::ENOENT)
17
+ end
18
+
19
+ it 'finds nothing' do
20
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
21
+ end
22
+ end
23
+
24
+ context 'installed' do
25
+ before do
26
+ allow(Open3).to receive(:capture2).with(*vswhere_args).and_return(vswhere_path)
27
+ end
28
+
29
+ context 'fails' do
30
+ let(:vswhere_path) do
31
+ [
32
+ 'vswhere crashed',
33
+ OpenStruct.new(success?: false)
34
+ ]
35
+ end
9
36
 
10
- context 'on Windows',
11
- skip: ('Windows Registry not available' unless defined?(::Win32::Registry)) do
12
- let(:windows?) { true }
37
+ before do
38
+ allow(described_class).to receive(:warn)
39
+ end
13
40
 
41
+ it 'finds nothing' do
42
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
43
+ end
44
+
45
+ it 'warns about the crash' do
46
+ described_class.find rescue nil # rubocop:disable Style/RescueModifier
47
+ expect(described_class).to have_received(:warn).with(/^vswhere failed:/)
48
+ end
49
+ end
50
+
51
+ describe 'MSBuild executable' do
52
+ let(:vswhere_path) do
53
+ [
54
+ 'c:\path',
55
+ OpenStruct.new(success?: true)
56
+ ]
57
+ end
58
+
59
+ before do
60
+ allow(Dir).to receive(:[]).with('c:/path/MSBuild/*/Bin/MSBuild.exe')
61
+ .and_return(['c:/path/msbuild.exe'])
62
+ end
63
+
64
+ context 'exists' do
65
+ before do
66
+ allow(File).to receive(:file?).with('c:/path/msbuild.exe').and_return(true)
67
+ end
68
+
69
+ it 'finds msbuild.exe' do
70
+ expect(described_class.find).to eq('c:/path/msbuild.exe')
71
+ end
72
+ end
73
+
74
+ context 'does not exist' do
75
+ before do
76
+ allow(File).to receive(:exist?).with('c:/path/msbuild.exe').and_return(false)
77
+ end
78
+
79
+ it 'finds nothing' do
80
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ context 'Registry',
88
+ skip: ('Windows Registry not available on this platform' unless defined?(::Win32::Registry)) do
14
89
  before do
15
90
  allow(::Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).and_yield('MSBuildToolsPath' => 'path')
16
91
  end
17
92
 
18
- it 'should search the registry for known MSBuild versions' do
19
- described_class.find
93
+ it 'searches the registry for known MSBuild versions' do
94
+ described_class.find rescue nil # rubocop:disable Style/RescueModifier
20
95
  expect(::Win32::Registry::HKEY_LOCAL_MACHINE).to have_received(:open).at_least(:once)
21
96
  end
22
97
 
23
- context 'key not found' do
98
+ context 'Registry key not found' do
24
99
  before do
25
100
  allow(::Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).and_raise(::Win32::Registry::Error.new(3))
26
101
  end
27
102
 
28
103
  it 'finds nothing' do
29
- expect(described_class.find).to be_nil
104
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
30
105
  end
31
106
  end
32
107
 
33
- context 'MSBuild exists' do
34
- before do
35
- allow(File).to receive(:exist?).with('path/msbuild.exe').and_return(true)
36
- end
108
+ describe 'MSBuild executable' do
109
+ context 'exists' do
110
+ before do
111
+ allow(File).to receive(:exist?).with('path/msbuild.exe').and_return(true)
112
+ end
37
113
 
38
- it 'should find msbuild.exe' do
39
- expect(described_class.find).to eq('path/msbuild.exe')
114
+ it 'finds msbuild.exe' do
115
+ expect(described_class.find).to eq('path/msbuild.exe')
116
+ end
40
117
  end
41
- end
42
118
 
43
- context 'MSBuild does not exist' do
44
- before do
45
- allow(File).to receive(:exist?).with('path/msbuild.exe').and_return(false)
46
- end
119
+ context 'does not exist' do
120
+ before do
121
+ allow(File).to receive(:exist?).with('path/msbuild.exe').and_return(false)
122
+ end
47
123
 
48
- it 'should not find msbuild.exe' do
49
- expect(described_class.find).to be_nil
124
+ it 'finds nothing' do
125
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
126
+ end
50
127
  end
51
128
  end
52
129
  end
53
130
 
54
- context 'not on Windows' do
55
- let(:windows?) { false }
131
+ context 'mono' do
132
+ before do
133
+ allow(described_class).to receive(:require).with('win32/registry').and_raise(LoadError)
134
+ allow(Open3).to receive(:capture2).with('vswhere.exe', any_args).and_raise(Errno::ENOENT)
135
+ end
56
136
 
57
- context 'mono not installed' do
137
+ context 'not installed' do
58
138
  before do
59
139
  allow(Open3).to receive(:capture2).with('mono', '--version').and_raise(Errno::ENOENT)
60
140
  end
61
141
 
62
- it 'fails' do
63
- expect { described_class.find }.to raise_error('mono is not installed')
142
+ it 'finds nothing' do
143
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
64
144
  end
65
145
  end
66
146
 
67
- context 'mono installed' do
147
+ context 'installed' do
68
148
  before do
69
149
  allow(Open3).to receive(:capture2).with('mono', '--version').and_return(mono_version)
70
150
  end
71
151
 
72
- context 'mono fails' do
152
+ context 'fails' do
73
153
  let(:mono_version) do
74
154
  [
75
155
  'mono crashed',
@@ -77,8 +157,17 @@ describe Rake::Funnel::Support::MSBuild::BuildTool do
77
157
  ]
78
158
  end
79
159
 
80
- it 'should find nothing' do
81
- expect { described_class.find }.to raise_error(/^Could not determine mono version:/)
160
+ before do
161
+ allow(described_class).to receive(:warn)
162
+ end
163
+
164
+ it 'finds nothing' do
165
+ expect { described_class.find }.to raise_error('No compatible MSBuild build tool was found')
166
+ end
167
+
168
+ it 'warns about the crash' do
169
+ described_class.find rescue nil # rubocop:disable Style/RescueModifier
170
+ expect(described_class).to have_received(:warn).with(/^Could not determine mono version:/)
82
171
  end
83
172
  end
84
173
 
@@ -90,7 +179,7 @@ describe Rake::Funnel::Support::MSBuild::BuildTool do
90
179
  ]
91
180
  end
92
181
 
93
- it 'should find xbuild' do
182
+ it 'finds xbuild' do
94
183
  expect(described_class.find).to eq('xbuild')
95
184
  end
96
185
  end
@@ -103,7 +192,7 @@ describe Rake::Funnel::Support::MSBuild::BuildTool do
103
192
  ]
104
193
  end
105
194
 
106
- it 'should find msbuild' do
195
+ it 'finds msbuild' do
107
196
  expect(described_class.find).to eq('msbuild')
108
197
  end
109
198
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Support::MSDeploy::RegistryPatch do
1
+ describe Rake::Funnel::Support::MSDeploy::RegistryPatch do # rubocop:disable RSpec/FilePath
4
2
  before do
5
3
  # rubocop:disable RSpec/AnyInstance
6
4
  allow_any_instance_of(described_class).to receive(:warn)
@@ -11,7 +11,7 @@ describe Rake::Funnel::Support::Timing::Report do
11
11
  subject.render
12
12
  end
13
13
 
14
- shared_examples_for :report do
14
+ shared_examples_for 'report' do
15
15
  it 'should separator lines' do
16
16
  expect($stdout).to have_received(:puts)
17
17
  .with(Regexp.new('-' * described_class::HEADER_WIDTH)).exactly(4).times
@@ -49,7 +49,7 @@ describe Rake::Funnel::Support::Timing::Report do
49
49
  describe 'empty report', include: Rake::Funnel::Support::Timing do
50
50
  let(:stats) { Rake::Funnel::Support::Timing::Statistics.new }
51
51
 
52
- it_behaves_like :report
52
+ it_behaves_like 'report'
53
53
  end
54
54
 
55
55
  describe 'report for 2 tasks' do
@@ -60,7 +60,7 @@ describe Rake::Funnel::Support::Timing::Report do
60
60
  s
61
61
  end
62
62
 
63
- it_behaves_like :report
63
+ it_behaves_like 'report'
64
64
 
65
65
  it 'should print each task' do
66
66
  expect($stdout).to have_received(:puts).with(/^foo/)
@@ -95,7 +95,7 @@ describe Rake::Funnel::Support::Timing::Report do
95
95
  diff + described_class::SPACE
96
96
  end
97
97
 
98
- shared_examples_for :padding do
98
+ shared_examples_for 'padding' do
99
99
  it 'should pad headers' do
100
100
  expect($stdout).to have_received(:puts)
101
101
  .with(Regexp.new("^#{subject.columns[0].header}\\s{#{header_space}}#{subject.columns[1].header}"))
@@ -113,13 +113,13 @@ describe Rake::Funnel::Support::Timing::Report do
113
113
  context 'task names are shorter than headers' do
114
114
  let(:task_name) { :a }
115
115
 
116
- it_behaves_like :padding
116
+ it_behaves_like 'padding'
117
117
  end
118
118
 
119
119
  context 'task names are longer than headers' do
120
120
  let(:task_name) { :aaaaaaaaaaaa }
121
121
 
122
- it_behaves_like :padding
122
+ it_behaves_like 'padding'
123
123
  end
124
124
  end
125
125
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Tasks::MSBuild do
1
+ describe Rake::Funnel::Tasks::MSBuild do # rubocop:disable RSpec/FilePath
4
2
  before do
5
3
  Rake::Task.clear
6
4
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Tasks::MSDeploy do
1
+ describe Rake::Funnel::Tasks::MSDeploy do # rubocop:disable RSpec/FilePath
4
2
  before do
5
3
  Rake::Task.clear
6
4
  end
@@ -1,6 +1,4 @@
1
- # rubocop:disable RSpec/FilePath
2
-
3
- describe Rake::Funnel::Tasks::NUnit do
1
+ describe Rake::Funnel::Tasks::NUnit do # rubocop:disable RSpec/FilePath
4
2
  before do
5
3
  Rake::Task.clear
6
4
  end
@@ -4,15 +4,15 @@ describe Rake::Funnel::Tasks::Timing do
4
4
  before do
5
5
  Rake.application = nil
6
6
  Rake::Task.clear
7
-
8
- # rubocop:disable RSpec/ExpectInHook
9
- expect(define_tasks).to be
10
- expect(subject).to be
11
- # rubocop:enable RSpec/ExpectInHook
12
7
  end
13
8
 
14
9
  let(:define_tasks) { task :task }
15
10
 
11
+ subject! do
12
+ define_tasks
13
+ described_class.new
14
+ end
15
+
16
16
  after do
17
17
  subject.reset!
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-funnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.2
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Groß
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-16 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configatron
@@ -81,6 +81,7 @@ extra_rdoc_files: []
81
81
  files:
82
82
  - ".rspec"
83
83
  - ".simplecov"
84
+ - CHANGELOG.md
84
85
  - Gemfile
85
86
  - README.md
86
87
  - lib/rake/funnel.rb
@@ -233,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
234
  version: '0'
234
235
  requirements: []
235
236
  rubyforge_project:
236
- rubygems_version: 2.6.14
237
+ rubygems_version: 2.7.3
237
238
  signing_key:
238
239
  specification_version: 4
239
240
  summary: A build pipeline targeted at .NET projects. Supports environment configuration