From a6f9bfcb88df4de20d97db2c7b1e749acac3913e Mon Sep 17 00:00:00 2001 From: Dimitris Koutsogiorgas Date: Thu, 20 Aug 2020 15:48:42 -0700 Subject: [PATCH] Honor test spec deployment target during validation. --- .rubocop_todo.yml | 2 +- CHANGELOG.md | 4 +++ lib/cocoapods/validator.rb | 10 +++--- .../pod_target_installer_spec.rb | 4 +-- spec/unit/validator_spec.rb | 33 +++++++++++++++++++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d38c5ef912..5e424b137c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -237,7 +237,7 @@ Lint/UselessAccessModifier: # Offense count: 373 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Max: 1445 + Max: 1476 # Offense count: 7099 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc4995456..befcb60bc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes +* Honor test spec deployment target during validation. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#9999](https://github.com/CocoaPods/CocoaPods/pull/9999) + * Ensure that incremental installation is able to set target dependencies for a test spec that uses a custom `app_host_name` that is in a project that is not regenerated. diff --git a/lib/cocoapods/validator.rb b/lib/cocoapods/validator.rb index 57e838e60e..1ea578ee3a 100644 --- a/lib/cocoapods/validator.rb +++ b/lib/cocoapods/validator.rb @@ -556,6 +556,8 @@ def clean! validation_dir.rmtree end + # @return [String] The deployment targret of the library spec. + # def deployment_target deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name) if consumer.platform_name == :ios && use_frameworks @@ -711,7 +713,7 @@ def build_pod UI.warn "Skipping compilation with `xcodebuild` because target contains no sources.\n".yellow else if analyze - output = xcodebuild('analyze', scheme, 'Release') + output = xcodebuild('analyze', scheme, 'Release', :deployment_target => deployment_target) find_output = Executable.execute_command('find', [validation_dir, '-name', '*.html'], false) if find_output != '' message = 'Static Analysis failed.' @@ -720,7 +722,7 @@ def build_pod error('build_pod', message) end else - output = xcodebuild('build', scheme, configuration ? configuration : 'Release') + output = xcodebuild('build', scheme, configuration ? configuration : 'Release', :deployment_target => deployment_target) end parsed_output = parse_xcodebuild_output(output) translate_output_to_linter_messages(parsed_output) @@ -757,7 +759,7 @@ def test_pod UI.warn "Skipping test spec `#{test_spec.name}` on platform `#{consumer.platform_name}` since it is not supported.\n".yellow else scheme = @installer.target_installation_results.first[pod_target.name].native_target_for_spec(test_spec) - output = xcodebuild('test', scheme, 'Debug') + output = xcodebuild('test', scheme, 'Debug', :deployment_target => test_spec.deployment_target(consumer.platform_name)) parsed_output = parse_xcodebuild_output(output) translate_output_to_linter_messages(parsed_output) end @@ -1048,7 +1050,7 @@ def parse_xcodebuild_output(output) # @return [String] Executes xcodebuild in the current working directory and # returns its output (both STDOUT and STDERR). # - def xcodebuild(action, scheme, configuration) + def xcodebuild(action, scheme, configuration, deployment_target:) require 'fourflusher' command = %W(clean #{action} -workspace #{File.join(validation_dir, 'App.xcworkspace')} -scheme #{scheme} -configuration #{configuration}) case consumer.platform_name diff --git a/spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb b/spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb index bf5aa81055..64e4efb2fe 100644 --- a/spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb +++ b/spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb @@ -4,8 +4,8 @@ module Pod class Installer class Xcode class PodsProjectGenerator - describe PodTargetInstaller do # rubocop:disable Metrics/BlockLength - describe 'In General' do # rubocop:disable Metrics/BlockLength + describe PodTargetInstaller do + describe 'In General' do before do @banana_spec = fixture_spec('banana-lib/BananaLib.podspec') @project = Pod::Project.new(config.sandbox.project_path) diff --git a/spec/unit/validator_spec.rb b/spec/unit/validator_spec.rb index 2cce9e3476..242bf15aa3 100644 --- a/spec/unit/validator_spec.rb +++ b/spec/unit/validator_spec.rb @@ -600,6 +600,39 @@ def podspec_path(name = 'JSONKit', version = '1.4') validator.results_message.strip.should.be.empty end + it 'uses the deployment target of the current test spec' do + require 'fourflusher' + Validator.any_instance.unstub(:xcodebuild) + validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url)) + validator.use_frameworks = true + validator.instance_variable_set(:@results, []) + validator.stubs(:validate_url) + validator.stubs(:validate_screenshots) + validator.stubs(:check_file_patterns) + validator.stubs(:install_pod) + validator.stubs(:add_app_project_import) + %i(prepare resolve_dependencies download_dependencies write_lockfiles).each do |m| + Installer.any_instance.stubs(m) + end + Installer.any_instance.stubs(:aggregate_targets).returns([]) + Installer.any_instance.stubs(:pod_targets).returns([]) + validator.spec.ios.deployment_target = '8.0' + test_spec = Specification.new(validator.spec, 'testspec', true) do |s| + s.ios.deployment_target = '9.0' + end + validator.spec.stubs(:subspecs).returns([test_spec]) + pod_target = stub('JSONKit-PodTarget') + pod_target.stubs(:name).returns('JSONKit') + validator.stubs(:validation_pod_target).returns(pod_target) + target_installation_result = stub('JSONKitTargetInstallationResult') + target_installation_result.stubs(:native_target_for_spec).with(test_spec).returns('Testspec-Target') + Installer.any_instance.stubs(:target_installation_results).returns([{ 'JSONKit' => target_installation_result }]) + Fourflusher::SimControl.any_instance.expects(:destination).with(:oldest, 'iOS', '8.0').returns(['-destination', 'id=XXX']) + Fourflusher::SimControl.any_instance.expects(:destination).with(:oldest, 'iOS', '9.0').returns(['-destination', 'id=XXX']) + + validator.validate + end + describe '#podfile_from_spec' do before do @validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url))