8000 Add support for test target creation in the pods project generator by dnkoutso · Pull Request #6703 · CocoaPods/CocoaPods · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for test target creation in the pods project generator #6703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2017

Conversation

dnkoutso
Copy link
Contributor

No description provided.

Gemfile Outdated
@@ -25,7 +25,7 @@ gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be reverted.

Gemfile.lock Outdated
@@ -6,16 +6,6 @@ GIT
claide (1.0.1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be reverted.

@@ -176,40 +177,6 @@ def generate_settings_to_import_pod_targets
end
end

# Add custom build settings and required build settings to link to
Copy link
Contributor Author
@dnkoutso dnkoutso May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those moved to xcconfig_helper no changes here and specs pass for this class.

@@ -66,6 +70,11 @@ def generate
end
XCConfigHelper.add_target_specific_settings(target, @xcconfig)
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, target.recursive_dependent_targets)
if @test_xcconfig
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For test xcconfigs we ensure that linker flags are added for their dependencies.

ld_flags = ''
ld_flags << '-ObjC' if includes_static_libraries
ld_flags << '-ObjC' if include_objc_flag
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just rename of the flag here no real changes.

@@ -296,6 +298,55 @@ def self.settings_for_dependent_targets(target, dependent_targets)
build_settings
end

# Add custom build settings and required build settings to link to
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied pasted from aggregate_xcconfig.rb, almost zero changes except passing parameters.

@@ -86,6 +86,11 @@ def share_development_pod_schemes
development_pod_targets.select(&:should_build?).each do |pod_target|
next unless share_scheme_for_development_pod?(pod_target.pod_name)
Xcodeproj::XCScheme.share_scheme(project.path, pod_target.label)
if pod_target.contains_test_specifications?
Copy link
Contributor Author
@dnkoutso dnkoutso May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shares the xcscheme for tests :D

end
end
end
end

# TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take care of this

if target.requires_frameworks?
create_info_plist_file
create_module_map
create_umbrella_header do |generator|
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents adding test specification headers as part of the generated umbrella header

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to gate the reject on contains_test_specification - might be expensive to do this for larger projects that do not have test specs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice thanks for the tip will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dantoml done, also added a test case to ensure test header files never make it into umbrella header :)

end
end

# TODO: doc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix

@@ -234,7 +267,7 @@ def include_in_build_config?(target_definition, configuration_name)

if whitelists.empty?
@build_config_cache[key] = true
return true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just warning fix

@@ -258,7 +291,7 @@ def inhibit_warnings?

if whitelists.empty?
@inhibit_warnings = false
return false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just warning fix

@@ -268,7 +301,7 @@ def inhibit_warnings?
'settings to inhibit warnings. CocoaPods does not currently ' \
'support different settings and will fall back to your preference ' \
'set in the root target definition.'
return podfile.root_target_definitions.first.inhibits_warnings_for_pod?(root_spec.name)
podfile.root_target_definitions.first.inhibits_warnings_for_pod?(root_spec.name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just warning fix

@@ -0,0 +1,20 @@
Pod::Spec.new do |s|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New library that helps with test_spec support

@dnkoutso
Copy link
Contributor Author

@benasher44, @dantoml, @orta (and maybe @segiddins?) would love for you to review this PR at your time.

I need to add a few more specs but overall its 95% complete.

@@ -203,16 +208,10 @@ def set_target_dependencies
aggregate_target.native_target.add_dependency(pod_target.native_target)
configure_app_extension_api_only_for_target(pod_target) if is_app_extension

pod_target.dependent_targets.each do |pod_dependency_target|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method extracted. No logical changes. Helps support wiring up test dependencies to the native targets

@orta
Copy link
Member
orta commented May 11, 2017

@dnkoutso any chance you can upload a zip of an example project with this?

@dnkoutso
Copy link
Contributor Author

@orta will upload one today

@dnkoutso
Copy link
Contributor Author

@orta there you go.

Please keep in mind I am still using a Podfile to consume the test spec since the validator work is not done.

You will also need to ensure you setup cocoapods to point to my repo and branch so the integration works.

It's pretty awesome to see it in action :)

SampleProject.zip

@dnkoutso
Copy link
Contributor Author

Added a few more specs!

@dnkoutso dnkoutso requested review from mrackwitz, orta, benasher44 and endocrimes and removed request for mrackwitz May 11, 2017 18:55
@dnkoutso dnkoutso force-pushed the test_phase_1 branch 3 times, most recently from 1c1f5e9 to 1ddb50e Compare May 11, 2017 20:30
@dnkoutso
Copy link
Contributor Author

Should go green!

@dnkoutso dnkoutso force-pushed the test_phase_1 branch 2 times, most recently from c83133d to aa060c8 Compare May 11, 2017 21:15
@dnkoutso
Copy link
Contributor Author

Green!

Copy link
Member
@endocrimes endocrimes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work so far - this is actually looking to be pretty solid.

We'll definitely need guides for this - and potentially a separate project generation command for working on and testing pods outside of a host application project.

@@ -400,7 +489,7 @@ def header_mappings_dir
end
end

def add_header(build_file, public_headers, private_headers)
def add_header(build_file, public_headers, private_headers, native_target)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this added param is not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, the method uses native_target which is a property but now the parameter takes over so no real method changes were required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh - lol shadowing

if target.requires_frameworks?
create_info_plist_file
create_module_map
create_umbrella_header do |generator|
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to gate the reject on contains_test_specification - might be expensive to do this for larger projects that do not have test specs

@dnkoutso dnkoutso force-pushed the test_phase_1 branch 2 times, most recently from da8af81 to 58cb912 Compare May 15, 2017 06:25
@dnkoutso
Copy link
Contributor Author

All set.

@orta
Copy link
Member
orta commented May 15, 2017

I wonder if we can do something about making cmd + u work for the project. Right now, tests only work inside the actual test target.

I wonder if we can make it work both for the library:

So for this setup:
screen shot 2017-05-15 at 10 40 59

Ideally cmd + u on Pods-SampleProject, and SampleLibrary would also work. It would run any tests for any pod-targets that are linked to the "cocoapods target"

@endocrimes
Copy link
Member

@orta Yeah it would be pretty nice if we added the testable to the main scheme

@dnkoutso
Copy link
Contributor Author

Yes! So CMD+U works today on the test scheme but only if you decide to have share_development_pod_schemes enabled.

Second, Xcodeproj has a method called recreate_user_schemes so I tried to edit the xcconfigs but there we being "nuked" again and re-written by this method.

I think we should expose a block in the Xcodeproj method and allow us to perform various customization on the schemes before we save them, so we don't have to do a post-process step and save them twice which can be slow for multiple files.

Is this a blocker in this PR?

@orta
Copy link
Member
orta commented May 15, 2017

IMO, ideally that gets looked at before the RC releases, but I don't consider it a blocker on this PR which is "get it in" vs "make it perfect"

@dnkoutso
Copy link
Contributor Author

With your blessing we can get this merged and start a bit the process of polishing it!

I got an upcoming branch with validator changes for running tests during lint

Copy link
Member
@endocrimes endocrimes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets get this on master and we can polish it as we go.

@dnkoutso
Copy link
Contributor Author

<3!

@dnkoutso dnkoutso merged commit 5ae791f into CocoaPods:master May 15, 2017
@segiddins
Copy link
Member

🍾 well done, @dnkoutso !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0