rake-funnel 0.19.0 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d994a7aee19d9d6394f52bd560fceb3e7c1d0dba
4
- data.tar.gz: 845d2b7a7862dcb29bfbdc3c06bc7a4620ccb585
3
+ metadata.gz: b99056aebd3a09e71ec855cade4b7f6264438eeb
4
+ data.tar.gz: 48d023a394a4186fc41ddc5d0d23364130b17636
5
5
  SHA512:
6
- metadata.gz: f473e9b4620d0c95e97a729ae1eb65fd148e5088203218a377ece7900f5283d38f57b57fa04411a669e05b7d185096e045fb63af063f1084eeaf777f8fd3d8b6
7
- data.tar.gz: 8dad0dae6e75d942e9e04045ff3d1cdf0d6e953bba0001d3dd87f548f721f29711f0698481eb56addcbca58ab23b57c5acc91da0428952a7b9c0c4d7c464d491
6
+ metadata.gz: 98ebf19ad3366a58385c196c966b6c4d98f51dc3a258673893390a34a03af3ad3cc271fe2d691c349246e83c9167145589bcd8c25eb1621774557fa7120610f2
7
+ data.tar.gz: 0e7958003263910ff6d441cfd62c8654c10885cd260ad4a27def148fecc3761a1f1bdb459b9512048b0766640491d0f1795dc0eaaa692898a2ecd391cdb9a3e3
@@ -1,3 +1,5 @@
1
+ require 'open3'
2
+
1
3
  module Rake
2
4
  module Funnel
3
5
  module Support
@@ -5,13 +7,26 @@ module Rake
5
7
  class BuildTool
6
8
  class << self
7
9
  def find
8
- return 'xbuild'.freeze unless Rake::Win32.windows?
9
-
10
- from_registry.compact.first
10
+ [mono_build, from_registry].compact.first
11
11
  end
12
12
 
13
13
  private
14
14
 
15
+ def mono_build
16
+ return nil if Rake::Win32.windows?
17
+
18
+ begin
19
+ out, status = Open3.capture2('mono', '--version')
20
+ return nil unless status.success?
21
+ rescue Errno::ENOENT
22
+ return nil
23
+ end
24
+
25
+ return 'msbuild'.freeze if out[/^Mono JIT compiler version ([\d\.]+)/, 1] >= '5.0'
26
+
27
+ 'xbuild'.freeze
28
+ end
29
+
15
30
  KEY = 'SOFTWARE\Microsoft\MSBuild\ToolsVersions'.freeze
16
31
 
17
32
  def from_registry
@@ -7,7 +7,7 @@ module Rake
7
7
  include Rake::Funnel::Support
8
8
  include Rake::Funnel::Support::MSBuild
9
9
 
10
- attr_accessor :name, :msbuild, :project_or_solution, :args, :search_pattern
10
+ attr_accessor :name, :msbuild, :msbuild_finder, :project_or_solution, :args, :search_pattern
11
11
  attr_writer :project_or_solution
12
12
 
13
13
  def initialize(*args, &task_block)
@@ -25,19 +25,20 @@ module Rake
25
25
  def setup_ivars(args)
26
26
  @name = args.shift || :compile
27
27
 
28
- @msbuild = BuildTool.find
28
+ @msbuild = nil
29
+ @msbuild_finder = ->() { BuildTool.find }
29
30
  @args = {}
30
31
  @search_pattern = %w(**/*.sln)
31
32
  end
32
33
 
33
- def define(args, &task_block) # rubocop:disable Metrics/MethodLength
34
+ def define(args, &task_block) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
34
35
  desc 'Compile MSBuild projects' unless Rake.application.last_description
35
36
 
36
37
  task(name, *args) do |_, task_args|
37
38
  yield(*[self, task_args].slice(0, task_block.arity)) if task_block
38
39
 
39
40
  cmd = [
40
- msbuild,
41
+ msbuild || msbuild_finder.call,
41
42
  project_or_solution.single,
42
43
  *Mapper.new(:MSBuild).map(@args)
43
44
  ]
@@ -1,5 +1,5 @@
1
1
  module Rake
2
2
  module Funnel
3
- VERSION = '0.19.0'.freeze
3
+ VERSION = '0.20.0'.freeze
4
4
  end
5
5
  end
@@ -1,5 +1,7 @@
1
1
  # rubocop:disable RSpec/FilePath
2
2
 
3
+ require 'ostruct'
4
+
3
5
  describe Rake::Funnel::Support::MSBuild::BuildTool do
4
6
  before do
5
7
  allow(Rake::Win32).to receive(:windows?).and_return(windows?)
@@ -18,6 +20,16 @@ describe Rake::Funnel::Support::MSBuild::BuildTool do
18
20
  expect(::Win32::Registry::HKEY_LOCAL_MACHINE).to have_received(:open).at_least(:once)
19
21
  end
20
22
 
23
+ context 'key not found' do
24
+ before do
25
+ allow(::Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).and_raise(::Win32::Registry::Error.new(3))
26
+ end
27
+
28
+ it 'finds nothing' do
29
+ expect(described_class.find).to be_nil
30
+ end
31
+ end
32
+
21
33
  context 'MSBuild exists' do
22
34
  before do
23
35
  allow(File).to receive(:exist?).with('path/msbuild.exe').and_return(true)
@@ -42,8 +54,64 @@ describe Rake::Funnel::Support::MSBuild::BuildTool do
42
54
  context 'not on Windows' do
43
55
  let(:windows?) { false }
44
56
 
45
- it 'should find xbuild' do
46
- expect(described_class.find).to eq('xbuild')
57
+ before do
58
+ allow(Open3).to receive(:capture2).with('mono', '--version').and_return(mono_version)
59
+ end
60
+
61
+ context 'mono not installed' do
62
+ let(:mono_version) do
63
+ [
64
+ 'mono crashed',
65
+ OpenStruct.new(success?: false)
66
+ ]
67
+ end
68
+
69
+ before do
70
+ allow(Open3).to receive(:capture2).with('mono', '--version').and_raise(Errno::ENOENT)
71
+ end
72
+
73
+ it 'should find nothing' do
74
+ expect(described_class.find).to be_nil
75
+ end
76
+ end
77
+
78
+ context 'mono fails' do
79
+ let(:mono_version) do
80
+ [
81
+ 'mono crashed',
82
+ OpenStruct.new(success?: false)
83
+ ]
84
+ end
85
+
86
+ it 'should find nothing' do
87
+ expect(described_class.find).to be_nil
88
+ end
89
+ end
90
+
91
+ context 'mono < 5.0' do
92
+ let(:mono_version) do
93
+ [
94
+ 'Mono JIT compiler version 4.8.1 (mono-4.8.0-branch/22a39d7 Fri Apr 7 12:00:08 EDT 2017)',
95
+ OpenStruct.new(success?: true)
96
+ ]
97
+ end
98
+
99
+ it 'should find xbuild' do
100
+ expect(described_class.find).to eq('xbuild')
101
+ end
102
+ end
103
+
104
+ context 'mono >= 5.0' do
105
+ let(:mono_version) do
106
+ [
107
+ 'Mono JIT compiler version 5.0.0.100 (2017-02/9667aa6 Fri May 5 09:12:57 EDT 2017)',
108
+ OpenStruct.new(success?: true)
109
+ ]
110
+ end
111
+
112
+ it 'should find msbuild' do
113
+ expect(described_class.find).to eq('msbuild')
114
+ end
47
115
  end
48
116
  end
49
117
  end
@@ -15,14 +15,15 @@ describe Rake::Funnel::Tasks::MSBuild do
15
15
  its(:project_or_solution) { should be_instance_of(Finder) }
16
16
  its(:args) { should == {} }
17
17
  its(:search_pattern) { should == %w(**/*.sln) }
18
+ its(:msbuild) { should be_nil }
18
19
 
19
- describe 'build tool' do
20
+ describe 'build tool finder' do
20
21
  before do
21
22
  allow(BuildTool).to receive(:find).and_return('build tool')
22
23
  end
23
24
 
24
25
  it 'should use build tool finder' do
25
- expect(subject.msbuild).to eq('build tool')
26
+ expect(subject.msbuild_finder.call).to eq('build tool')
26
27
  end
27
28
  end
28
29
  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.19.0
4
+ version: 0.20.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: 2017-04-02 00:00:00.000000000 Z
11
+ date: 2017-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  requirements: []
235
235
  rubyforge_project:
236
- rubygems_version: 2.5.2
236
+ rubygems_version: 2.6.11
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: A build pipeline targeted at .NET projects. Supports environment configuration