Commit 204ab608 authored by Samuel Giddins's avatar Samuel Giddins Committed by Dimitris Koutsogiorgas

[Validator] Allow skipping import validation

parent 9e7c3c2e
......@@ -12,7 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* None.
* Add `--skip-import-validation` to skip linking a pod during lint.
[Samuel Giddins](https://github.com/segiddins)
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#5670](https://github.com/CocoaPods/CocoaPods/issues/5670)
## 1.2.0.rc.1 (2017-01-13)
......
......@@ -23,6 +23,7 @@ module Pod
['--private', 'Lint skips checks that apply only to public specs'],
['--swift-version=VERSION', 'The SWIFT_VERSION that should be used to lint the spec. ' \
'This takes precedence over a .swift-version file.'],
['--skip-import-validation', 'Lint skips validating that the pod can be imported'],
].concat(super)
end
......@@ -37,7 +38,8 @@ module Pod
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@private = argv.flag?('private', false)
@swift_version = argv.option('swift-version', nil)
@podspecs_paths = argv.arguments!
@skip_import_validation = argv.flag?('skip-import-validation', false)
@podspecs_paths = argv.arguments!
super
end
......@@ -59,6 +61,7 @@ module Pod
validator.use_frameworks = @use_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.skip_import_validation = @skip_import_validation
validator.validate
unless @clean
......
......@@ -29,6 +29,7 @@ module Pod
'Multiple sources must be comma-delimited.'],
['--local-only', 'Does not perform the step of pushing REPO to its remote'],
['--no-private', 'Lint includes checks that apply only to public repos'],
['--skip-import-validation', 'Lint skips validating that the pod can be imported'],
['--commit-message="Fix bug in pod"', 'Add custom commit message. ' \
'Opens default editor if no commit message is specified.'],
['--use-json', 'Push JSON spec to repo'],
......@@ -50,6 +51,7 @@ module Pod
@commit_message = argv.flag?('commit-message', false)
@use_json = argv.flag?('use-json')
@swift_version = argv.option('swift-version', nil)
@skip_import_validation = argv.flag?('skip-import-validation', false)
super
end
......@@ -127,6 +129,7 @@ module Pod
validator.use_frameworks = @use_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.skip_import_validation = @skip_import_validation
begin
validator.validate
rescue => e
......
......@@ -29,6 +29,7 @@ module Pod
['--private', 'Lint skips checks that apply only to public specs'],
['--swift-version=VERSION', 'The SWIFT_VERSION that should be used to lint the spec. ' \
'This takes precedence over a .swift-version file.'],
['--skip-import-validation', 'Lint skips validating that the pod can be imported'],
].concat(super)
end
......@@ -43,7 +44,8 @@ module Pod
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@private = argv.flag?('private', false)
@swift_version = argv.option('swift-version', nil)
@podspecs_paths = argv.arguments!
@skip_import_validation = argv.flag?('skip-import-validation', false)
@podspecs_paths = argv.arguments!
super
end
......@@ -61,6 +63,7 @@ module Pod
validator.use_frameworks = @use_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.skip_import_validation = @skip_import_validation
validator.validate
failure_reasons << validator.failure_reason
......
......@@ -202,6 +202,9 @@ module Pod
#
attr_accessor :ignore_public_only_results
attr_accessor :skip_import_validation
alias_method :skip_import_validation?, :skip_import_validation
#-------------------------------------------------------------------------#
# !@group Lint results
......@@ -411,7 +414,6 @@ module Pod
app_project.new_target(:application, 'App', consumer.platform_name, deployment_target)
app_project.save
app_project.recreate_user_schemes
Xcodeproj::XCScheme.share_scheme(app_project.path, 'App')
end
def add_app_project_import
......@@ -425,6 +427,8 @@ module Pod
add_swift_version(app_target)
add_xctest(app_target) if @installer.pod_targets.any? { |pt| pt.spec_consumers.any? { |c| c.frameworks.include?('XCTest') } }
app_project.save
Xcodeproj::XCScheme.share_scheme(app_project.path, 'App')
Xcodeproj::XCScheme.share_scheme(@installer.pods_project.path, pod_target.label)
end
def add_swift_version(app_target)
......@@ -764,7 +768,12 @@ module Pod
#
def xcodebuild
require 'fourflusher'
command = ['clean', 'build', '-workspace', File.join(validation_dir, 'App.xcworkspace'), '-scheme', 'App', '-configuration', 'Release']
scheme = if skip_import_validation?
@installer.pod_targets.find { |pt| pt.pod_name == spec.root.name }.label
else
'App'
end
command = %W(clean build -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration Release)
case consumer.platform_name
when :osx, :macos
command += %w(CODE_SIGN_IDENTITY=)
......
......@@ -295,6 +295,7 @@ module Pod
validator.stubs(:validate_url)
validator.expects(:install_pod).times(4)
validator.expects(:build_pod).times(4)
validator.expects(:add_app_project_import).times(4)
validator.expects(:check_file_patterns).times(4)
validator.validate
end
......@@ -423,6 +424,31 @@ module Pod
validator.result_type.should == :error
end
it 'runs xcodebuild with correct arguments when skipping import validation' do
require 'fourflusher'
Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX'])
Validator.any_instance.unstub(:xcodebuild)
validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url))
validator.stubs(:check_file_patterns)
validator.stubs(:validate_url)
validator.skip_import_validation = true
git = Executable.which(:git)
Executable.stubs(:which).with('git').returns(git)
Executable.stubs(:capture_command).with('git', ['config', '--get', 'remote.origin.url'], :capture => :out).returns(['https://github.com/CocoaPods/Specs.git'])
Executable.stubs(:which).with(:xcrun)
# Command should include the pod target 'JSONKit' instead of the 'App' target.
command = ['clean', 'build', '-workspace', File.join(validator.validation_dir, 'App.xcworkspace'), '-scheme', 'JSONKit', '-configuration', 'Release']
args = %w(CODE_SIGN_IDENTITY=)
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
args = %w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator) + Fourflusher::SimControl.new.destination('Apple TV 1080p')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
args = %w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator) + Fourflusher::SimControl.new.destination('iPhone 4s')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
args = %w(CODE_SIGN_IDENTITY=- -sdk watchsimulator) + Fourflusher::SimControl.new.destination('Apple Watch - 38mm')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
validator.validate
end
it 'runs xcodebuild with correct arguments for code signing' do
require 'fourflusher'
Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX'])
......@@ -582,9 +608,14 @@ module Pod
it 'adds the importing file to the app target' do
@validator.stubs(:use_frameworks).returns(true)
@validator.send(:create_app_project)
pods_project = Xcodeproj::Project.new(@validator.validation_dir + 'Pods/Pods.xcodeproj')
app_project_path = @validator.validation_dir + 'App.xcodeproj'
pod_target = fixture_pod_target('banana-lib/BananaLib.podspec')
pod_target.stubs(:uses_swift? => true, :pod_name => 'JSONKit')
installer = stub(:pod_targets => [pod_target])
installer.stubs(:pods_project).returns(pods_project)
Xcodeproj::XCScheme.expects(:share_scheme).with(app_project_path, 'App').once
Xcodeproj::XCScheme.expects(:share_scheme).with(pods_project.path, 'BananaLib').once
@validator.instance_variable_set(:@installer, installer)
@validator.send(:add_app_project_import)
......@@ -598,15 +629,20 @@ module Pod
it 'adds developer framework paths when the pod depends on XCTest' do
@validator.send(:create_app_project)
pods_project = Xcodeproj::Project.new(@validator.validation_dir + 'Pods/Pods.xcodeproj')
app_project_path = @validator.validation_dir + 'App.xcodeproj'
pod_target = fixture_pod_target('banana-lib/BananaLib.podspec')
pod_target.stubs(:uses_swift? => true, :pod_name => 'JSONKit')
pod_target.spec_consumers.first.stubs(:frameworks).returns(%w(XCTest))
installer = stub(:pod_targets => [pod_target])
installer.stubs(:pods_project).returns(pods_project)
Xcodeproj::XCScheme.expects(:share_scheme).with(app_project_path, 'App').once
Xcodeproj::XCScheme.expects(:share_scheme).with(pods_project.path, 'BananaLib').once
@validator.instance_variable_set(:@installer, installer)
@validator.send(:add_app_project_import)
project = Xcodeproj::Project.open(@validator.validation_dir + 'App.xcodeproj')
project.native_targets.first.build_configurations.map do |bc|
app_project = Xcodeproj::Project.open(app_project_path)
app_project.native_targets.first.build_configurations.map do |bc|
bc.build_settings['FRAMEWORK_SEARCH_PATHS']
end.uniq.should == [%w($(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks")]
end
......
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