Commit d4f72a82 authored by Samuel E. Giddins's avatar Samuel E. Giddins Committed by Boris Bügling

[Validator] Check file patterns before finishing installation

Also, rescue unknown extensive analysis exceptions and nicely error on them
parent 7523cb84
...@@ -244,15 +244,19 @@ module Pod ...@@ -244,15 +244,19 @@ module Pod
UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
@consumer = spec.consumer(platform) @consumer = spec.consumer(platform)
setup_validation_environment setup_validation_environment
download_pod
check_file_patterns
install_pod install_pod
validate_vendored_dynamic_frameworks validate_vendored_dynamic_frameworks
build_pod build_pod
check_file_patterns
tear_down_validation_environment tear_down_validation_environment
validated? validated?
end end
return false if fail_fast && !valid return false if fail_fast && !valid
perform_extensive_subspec_analysis(spec) unless @no_subspecs perform_extensive_subspec_analysis(spec) unless @no_subspecs
rescue => e
error('unknown', "Encountered an unknown error (#{e}) during validation.")
false
end end
# Recursively perform the extensive analysis on all subspecs # Recursively perform the extensive analysis on all subspecs
...@@ -334,29 +338,33 @@ module Pod ...@@ -334,29 +338,33 @@ module Pod
Config.instance = @original_config Config.instance = @original_config
end end
def download_pod
deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name)
podfile = podfile_from_spec(consumer.platform_name, deployment_target, use_frameworks)
sandbox = Sandbox.new(config.sandbox_root)
@installer = Installer.new(sandbox, podfile)
@installer.use_default_plugins = false
%i(prepare resolve_dependencies download_dependencies).each { |m| @installer.send(m) }
@file_accessor = @installer.pod_targets.flat_map(&:file_accessors).find { |fa| fa.spec.name == consumer.spec.name }
end
# It creates a podfile in memory and builds a library containing the pod # It creates a podfile in memory and builds a library containing the pod
# for all available platforms with xcodebuild. # for all available platforms with xcodebuild.
# #
def install_pod def install_pod
deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name) %i(determine_dependency_product_types verify_no_duplicate_framework_names
podfile = podfile_from_spec(consumer.platform_name, deployment_target, use_frameworks) verify_no_static_framework_transitive_dependencies
sandbox = Sandbox.new(config.sandbox_root) verify_framework_usage generate_pods_project
installer = Installer.new(sandbox, podfile) perform_post_install_actions).each { |m| @installer.send(m) }
installer.use_default_plugins = false
installer.install!
file_accessors = installer.aggregate_targets.map do |target| deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name)
@installer.aggregate_targets.each do |target|
if target.pod_targets.any?(&:uses_swift?) && consumer.platform_name == :ios && if target.pod_targets.any?(&:uses_swift?) && consumer.platform_name == :ios &&
(deployment_target.nil? || Version.new(deployment_target).major < 8) (deployment_target.nil? || Version.new(deployment_target).major < 8)
uses_xctest = target.spec_consumers.any? { |c| (c.frameworks + c.weak_frameworks).include? 'XCTest' } uses_xctest = target.spec_consumers.any? { |c| (c.frameworks + c.weak_frameworks).include? 'XCTest' }
error('swift', 'Swift support uses dynamic frameworks and is therefore only supported on iOS > 8.') unless uses_xctest error('swift', 'Swift support uses dynamic frameworks and is therefore only supported on iOS > 8.') unless uses_xctest
end end
end
target.pod_targets.map(&:file_accessors)
end.flatten
@file_accessor = file_accessors.find { |accessor| accessor.spec.root.name == spec.root.name }
config.silent
end end
def validate_vendored_dynamic_frameworks def validate_vendored_dynamic_frameworks
...@@ -546,11 +554,11 @@ module Pod ...@@ -546,11 +554,11 @@ module Pod
# in local mode. # in local mode.
# #
def podfile_from_spec(platform_name, deployment_target, use_frameworks = true) def podfile_from_spec(platform_name, deployment_target, use_frameworks = true)
name = subspec_name ? subspec_name : spec.name name = subspec_name || spec.name
podspec = file.realpath podspec = file.realpath
local = local? local = local?
urls = source_urls urls = source_urls
podfile = Pod::Podfile.new do Pod::Podfile.new do
urls.each { |u| source(u) } urls.each { |u| source(u) }
use_frameworks!(use_frameworks) use_frameworks!(use_frameworks)
platform(platform_name, deployment_target) platform(platform_name, deployment_target)
...@@ -560,7 +568,6 @@ module Pod ...@@ -560,7 +568,6 @@ module Pod
pod name, :podspec => podspec.to_s pod name, :podspec => podspec.to_s
end end
end end
podfile
end end
# Parse the xcode build output to identify the lines which are relevant # Parse the xcode build output to identify the lines which are relevant
......
...@@ -114,9 +114,12 @@ module Pod ...@@ -114,9 +114,12 @@ module Pod
end end
before do before do
%i(prepare resolve_dependencies download_dependencies).each do |m|
Installer.any_instance.stubs(m)
end
Installer.any_instance.stubs(:aggregate_targets).returns([]) Installer.any_instance.stubs(:aggregate_targets).returns([])
Installer.any_instance.stubs(:install!) Installer.any_instance.stubs(:pod_targets).returns([])
Validator.any_instance.stubs(:install_pod)
Validator.any_instance.stubs(:check_file_patterns) Validator.any_instance.stubs(:check_file_patterns)
Validator.any_instance.stubs(:validated?).returns(true) Validator.any_instance.stubs(:validated?).returns(true)
Validator.any_instance.stubs(:validate_url) Validator.any_instance.stubs(:validate_url)
......
...@@ -99,9 +99,10 @@ module Pod ...@@ -99,9 +99,10 @@ module Pod
describe 'URL validation' do describe 'URL validation' do
before do before do
@validator = Validator.new(podspec_path, SourcesManager.master.map(&:url)) @validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@validator.stubs(:download_pod)
@validator.stubs(:check_file_patterns)
@validator.stubs(:install_pod) @validator.stubs(:install_pod)
@validator.stubs(:build_pod) @validator.stubs(:build_pod)
@validator.stubs(:check_file_patterns)
@validator.stubs(:tear_down_validation_environment) @validator.stubs(:tear_down_validation_environment)
WebMock::API.stub_request(:head, /not-found/).to_return(:status => 404) WebMock::API.stub_request(:head, /not-found/).to_return(:status => 404)
WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404) WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404)
...@@ -300,8 +301,12 @@ module Pod ...@@ -300,8 +301,12 @@ module Pod
validator.stubs(:validate_screenshots) validator.stubs(:validate_screenshots)
validator.stubs(:check_file_patterns) validator.stubs(:check_file_patterns)
validator.stubs(:check_file_patterns) validator.stubs(:check_file_patterns)
Installer.any_instance.stubs(:install!) validator.stubs(:install_pod)
%i(prepare resolve_dependencies download_dependencies).each do |m|
Installer.any_instance.stubs(m)
end
Installer.any_instance.stubs(:aggregate_targets).returns([]) Installer.any_instance.stubs(:aggregate_targets).returns([])
Installer.any_instance.stubs(:pod_targets).returns([])
subspec = Specification.new(validator.spec, 'subspec') do |s| subspec = Specification.new(validator.spec, 'subspec') do |s|
s.ios.deployment_target = '7.0' s.ios.deployment_target = '7.0'
end end
...@@ -508,8 +513,12 @@ module Pod ...@@ -508,8 +513,12 @@ module Pod
@validator.stubs(:validate_url) @validator.stubs(:validate_url)
@validator.stubs(:validate_screenshots) @validator.stubs(:validate_screenshots)
@validator.stubs(:check_file_patterns) @validator.stubs(:check_file_patterns)
Installer.any_instance.stubs(:install!) @validator.stubs(:install_pod)
%i(prepare resolve_dependencies download_dependencies).each do |m|
Installer.any_instance.stubs(m)
end
Installer.any_instance.stubs(:aggregate_targets).returns([]) Installer.any_instance.stubs(:aggregate_targets).returns([])
Installer.any_instance.stubs(:pod_targets).returns([])
end end
it 'lints as a framework if specified' do it 'lints as a framework if specified' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment