Commit 43499f22 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Validator] Check file patterns before finishing installation

Also, rescue unknown extensive analysis exceptions and nicely error on them
parent 5121dff5
......@@ -244,15 +244,19 @@ module Pod
UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
@consumer = spec.consumer(platform)
setup_validation_environment
download_pod
check_file_patterns
install_pod
validate_vendored_dynamic_frameworks
build_pod
check_file_patterns
tear_down_validation_environment
validated?
end
return false if fail_fast && !valid
perform_extensive_subspec_analysis(spec) unless @no_subspecs
rescue => e
error('unknown', "Encountered an unknown error (#{e}) during validation.")
false
end
# Recursively perform the extensive analysis on all subspecs
......@@ -334,29 +338,33 @@ module Pod
Config.instance = @original_config
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
# for all available platforms with xcodebuild.
#
def install_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
installer.install!
%i(determine_dependency_product_types verify_no_duplicate_framework_names
verify_no_static_framework_transitive_dependencies
verify_framework_usage generate_pods_project
perform_post_install_actions).each { |m| @installer.send(m) }
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 &&
(deployment_target.nil? || Version.new(deployment_target).major < 8)
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
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
......@@ -546,11 +554,11 @@ module Pod
# in local mode.
#
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
local = local?
urls = source_urls
podfile = Pod::Podfile.new do
Pod::Podfile.new do
urls.each { |u| source(u) }
use_frameworks!(use_frameworks)
platform(platform_name, deployment_target)
......@@ -560,7 +568,6 @@ module Pod
pod name, :podspec => podspec.to_s
end
end
podfile
end
# Parse the xcode build output to identify the lines which are relevant
......
......@@ -114,9 +114,12 @@ module Pod
end
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(: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(:validated?).returns(true)
Validator.any_instance.stubs(:validate_url)
......
......@@ -99,9 +99,10 @@ module Pod
describe 'URL validation' do
before do
@validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@validator.stubs(:download_pod)
@validator.stubs(:check_file_patterns)
@validator.stubs(:install_pod)
@validator.stubs(:build_pod)
@validator.stubs(:check_file_patterns)
@validator.stubs(:tear_down_validation_environment)
WebMock::API.stub_request(:head, /not-found/).to_return(:status => 404)
WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404)
......@@ -300,8 +301,12 @@ module Pod
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(:pod_targets).returns([])
subspec = Specification.new(validator.spec, 'subspec') do |s|
s.ios.deployment_target = '7.0'
end
......@@ -508,8 +513,12 @@ module Pod
@validator.stubs(:validate_url)
@validator.stubs(:validate_screenshots)
@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(:pod_targets).returns([])
end
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