rewrite compatible_with_platform to not use sugar
This commit is contained in:
Родитель
fa0d5e0f3b
Коммит
50b5257a04
|
@ -1,5 +1,4 @@
|
|||
include Chef::Mixin::ShellOut
|
||||
include Chef::Sugar::Platform
|
||||
include MacOS
|
||||
|
||||
module MacOS
|
||||
|
@ -23,10 +22,16 @@ module MacOS
|
|||
end
|
||||
end
|
||||
|
||||
def compatible_with_platform?(node)
|
||||
return true if mac_os_x_after_or_at_high_sierra?(node)
|
||||
vintage_xcode = Gem::Dependency.new('Xcode', '< 9.3')
|
||||
vintage_xcode.match?('Xcode', @semantic_version)
|
||||
def compatible_with_platform?(macos_version)
|
||||
Gem::Dependency.new('macOS', minimum_required_os).match?('macOS', macos_version)
|
||||
end
|
||||
|
||||
def minimum_required_os
|
||||
return '>= 10.12.6' if Gem::Dependency.new('Xcode', '<= 9.2').match?('Xcode', @semantic_version)
|
||||
return '>= 10.13.2' if Gem::Dependency.new('Xcode', '>= 9.3', '<= 9.4.1').match?('Xcode', @semantic_version)
|
||||
return '>= 10.13.6' if Gem::Dependency.new('Xcode', '>= 10.0', '<= 10.1').match?('Xcode', @semantic_version)
|
||||
return '>= 10.14.3' if Gem::Dependency.new('Xcode', '>= 10.2', '<= 10.3').match?('Xcode', @semantic_version)
|
||||
return '>= 10.14.4' if Gem::Dependency.new('Xcode', '>= 11.0').match?('Xcode', @semantic_version)
|
||||
end
|
||||
|
||||
def xcode_index(version)
|
||||
|
|
|
@ -36,7 +36,7 @@ action :install_xcode do
|
|||
new_resource.download_url
|
||||
)
|
||||
|
||||
unless xcode.compatible_with_platform?(node)
|
||||
unless xcode.compatible_with_platform?(node['platform_version'])
|
||||
ruby_block 'exception' do
|
||||
raise("Xcode #{xcode.version} not supported before macOS High Sierra")
|
||||
end
|
||||
|
|
|
@ -56,7 +56,10 @@ describe MacOS::Xcode do
|
|||
"9.4\n",
|
||||
"9.4.1\n",
|
||||
"9.4.2 beta 2\n",
|
||||
"10 GM seed\n"]
|
||||
"10 GM seed\n",
|
||||
"10.1\n",
|
||||
"10.3\n",
|
||||
"11.0\n"]
|
||||
)
|
||||
end
|
||||
it 'returns the name of Xcode 10 GM when initialized with the semantic version' do
|
||||
|
@ -83,6 +86,46 @@ describe MacOS::Xcode do
|
|||
xcode = MacOS::Xcode.new('8.3.3', '/Applications/Xcode.app')
|
||||
expect(xcode.version).to eq '8.3.3'
|
||||
end
|
||||
it 'correctly determines platform compatibility for Xcode 11' do
|
||||
xcode = MacOS::Xcode.new('11.0', '/Applications/Xcode.app')
|
||||
expect(xcode.compatible_with_platform?('10.14.4')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.14.3')).to be false
|
||||
expect(xcode.compatible_with_platform?('10.13.6')).to be false
|
||||
expect(xcode.compatible_with_platform?('10.13.2')).to be false
|
||||
expect(xcode.compatible_with_platform?('10.12.6')).to be false
|
||||
end
|
||||
it 'correctly determines platform compatibility for Xcode 10.3' do
|
||||
xcode = MacOS::Xcode.new('10.3', '/Applications/Xcode.app')
|
||||
expect(xcode.compatible_with_platform?('10.14.4')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.14.3')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.6')).to be false
|
||||
expect(xcode.compatible_with_platform?('10.13.2')).to be false
|
||||
expect(xcode.compatible_with_platform?('10.12.6')).to be false
|
||||
end
|
||||
it 'correctly determines platform compatibility for Xcode 10.1' do
|
||||
xcode = MacOS::Xcode.new('10.1', '/Applications/Xcode.app')
|
||||
expect(xcode.compatible_with_platform?('10.14.4')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.14.3')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.6')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.2')).to be false
|
||||
expect(xcode.compatible_with_platform?('10.12.6')).to be false
|
||||
end
|
||||
it 'correctly determines platform compatibility for Xcode 9.4.1' do
|
||||
xcode = MacOS::Xcode.new('9.4.1', '/Applications/Xcode.app')
|
||||
expect(xcode.compatible_with_platform?('10.14.4')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.14.3')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.6')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.2')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.12.6')).to be false
|
||||
end
|
||||
it 'correctly determines platform compatibility for Xcode 9.2' do
|
||||
xcode = MacOS::Xcode.new('9.2', '/Applications/Xcode.app')
|
||||
expect(xcode.compatible_with_platform?('10.14.4')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.14.3')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.6')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.13.2')).to be true
|
||||
expect(xcode.compatible_with_platform?('10.12.6')).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче