Commit e2530f4b authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #3414 from CocoaPods/mr-xcassets-revised

[Spec|Doc|Fixture] Cleanup in preparation to a fixed xcasset handling
parents 1265bea9 8a8345a5
...@@ -91,19 +91,19 @@ begin ...@@ -91,19 +91,19 @@ begin
unit_specs_command = "bundle exec bacon #{specs('unit/**/*')}" unit_specs_command = "bundle exec bacon #{specs('unit/**/*')}"
desc 'Run the unit specs' desc 'Run the unit specs'
task :unit => :unpack_fixture_tarballs do task :unit => 'fixture_tarballs:unpack' do
sh unit_specs_command sh unit_specs_command
end end
desc 'Run the unit specs quietly (fail fast, display only one failure)' desc 'Run the unit specs quietly (fail fast, display only one failure)'
task :unit_quiet => :unpack_fixture_tarballs do task :unit_quiet => 'fixture_tarballs:unpack' do
sh "#{unit_specs_command} -q" sh "#{unit_specs_command} -q"
end end
#--------------------------------------# #--------------------------------------#
desc 'Run the functional specs' desc 'Run the functional specs'
task :functional, [:spec] => :unpack_fixture_tarballs do |_t, args| task :functional, [:spec] => 'fixture_tarballs:unpack' do |_t, args|
args.with_defaults(:spec => '**/*') args.with_defaults(:spec => '**/*')
sh "bundle exec bacon #{specs("functional/#{args[:spec]}")}" sh "bundle exec bacon #{specs("functional/#{args[:spec]}")}"
end end
...@@ -126,7 +126,7 @@ begin ...@@ -126,7 +126,7 @@ begin
# The specs helper interfere with the integration 2 specs and thus they need # The specs helper interfere with the integration 2 specs and thus they need
# to be run separately. # to be run separately.
# #
task :all => :unpack_fixture_tarballs do task :all => 'fixture_tarballs:unpack' do
ENV['GENERATE_COVERAGE'] = 'true' ENV['GENERATE_COVERAGE'] = 'true'
puts "\033[0;32mUsing #{`ruby --version`}\033[0m" puts "\033[0;32mUsing #{`ruby --version`}\033[0m"
...@@ -143,22 +143,42 @@ begin ...@@ -143,22 +143,42 @@ begin
Rake::Task['rubocop'].invoke Rake::Task['rubocop'].invoke
end end
desc 'Rebuild all the fixture tarballs' namespace :fixture_tarballs do
task :rebuild_fixture_tarballs do task :default => :unpack
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball| desc 'Check fixture tarballs for pending changes'
basename = File.basename(tarball) task :check_for_pending_changes do
sh "cd #{File.dirname(tarball)} && rm #{basename} && env COPYFILE_DISABLE=1 tar -zcf #{basename} #{basename[0..-8]}" repo_dir = 'spec/fixtures/banana-lib'
if Dir.exist?(repo_dir) && !Dir.chdir(repo_dir) { `git status --porcelain`.empty? }
puts red("[!] There are unsaved changes in '#{repo_dir}'. " \
'Please commit everything and run `rake spec:fixture_tarballs:rebuild`.')
exit 1
end
end
desc 'Rebuild all the fixture tarballs'
task :rebuild => :check_for_pending_changes do
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball|
basename = File.basename(tarball)
sh "cd #{File.dirname(tarball)} && rm #{basename} && env COPYFILE_DISABLE=1 tar -zcf #{basename} #{basename[0..-8]}"
end
end end
end
desc 'Unpacks all the fixture tarballs' desc 'Unpacks all the fixture tarballs'
task :unpack_fixture_tarballs do task :unpack, :force do |_t, args|
tarballs = FileList['spec/fixtures/**/*.tar.gz'] begin
tarballs.each do |tarball| Rake::Task['spec:fixture_tarballs:check_for_pending_changes'].invoke
basename = File.basename(tarball) rescue SystemExit
Dir.chdir(File.dirname(tarball)) do exit 1 unless args[:force]
sh "rm -rf #{basename[0..-8]} && tar zxf #{basename}" puts 'Continue anyway because `force` was applied.'
end
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball|
basename = File.basename(tarball)
Dir.chdir(File.dirname(tarball)) do
sh "rm -rf #{basename[0..-8]} && tar zxf #{basename}"
end
end end
end end
end end
...@@ -201,7 +221,7 @@ begin ...@@ -201,7 +221,7 @@ begin
puts 'Integration fixtures updated, commit and push in the `spec/cocoapods-integration-specs` submodule' puts 'Integration fixtures updated, commit and push in the `spec/cocoapods-integration-specs` submodule'
end end
task :clean_env => [:clean_vcr, :unpack_fixture_tarballs, 'ext:cleanbuild'] task :clean_env => [:clean_vcr, 'fixture_tarballs:unpack', 'ext:cleanbuild']
end end
# Examples # Examples
......
...@@ -130,8 +130,7 @@ module Pod ...@@ -130,8 +130,7 @@ module Pod
private_header_files private_header_files
end end
# @return [Hash{ Symbol => Array<Pathname> }] the resources of the # @return [Array<Pathname>] the resources of the specification.
# specification grouped by destination.
# #
def resources def resources
paths_for_attribute(:resources, true) paths_for_attribute(:resources, true)
...@@ -268,15 +267,22 @@ module Pod ...@@ -268,15 +267,22 @@ module Pod
# Matches the given patterns to the file present in the root of the path # Matches the given patterns to the file present in the root of the path
# list. # list.
# #
# @param [Array<String>] patterns # @param [Array<String>] patterns
# The patterns to expand. # The patterns to expand.
# #
# @param [String] dir_pattern # @param [Hash] options
# The options to use to expand the patterns to file paths.
#
# @option options [String] :dir_pattern
# The pattern to add to directories. # The pattern to add to directories.
# #
# @param [Array<String>] exclude_patterns # @option options [Array<String>] :exclude_patterns
# The exclude patterns to pass to the PathList. # The exclude patterns to pass to the PathList.
# #
# @option options [Bool] :include_dirs
# Whether directories should be also included or just plain
# files.
#
# @raise [Informative] If the pod does not exists. # @raise [Informative] If the pod does not exists.
# #
# @return [Array<Pathname>] A list of the paths. # @return [Array<Pathname>] A list of the paths.
......
...@@ -75,6 +75,7 @@ module Pod ...@@ -75,6 +75,7 @@ module Pod
file_accessors.map(&:readme), file_accessors.map(&:readme),
file_accessors.map(&:resources), file_accessors.map(&:resources),
file_accessors.map(&:source_files), file_accessors.map(&:source_files),
file_accessors.map(&:module_map),
] ]
files.flatten.compact.map(&:to_s).uniq files.flatten.compact.map(&:to_s).uniq
......
...@@ -2,6 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,6 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Installer::PodSourceInstaller do describe Installer::PodSourceInstaller do
FIXTURE_HEAD = Dir.chdir(SpecHelper.fixture('banana-lib')) { `git rev-parse HEAD`.chomp }
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@spec.source = { :git => SpecHelper.fixture('banana-lib') } @spec.source = { :git => SpecHelper.fixture('banana-lib') }
...@@ -25,7 +27,7 @@ module Pod ...@@ -25,7 +27,7 @@ module Pod
config.sandbox.store_head_pod('BananaLib') config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' } @spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install! @installer.install!
@installer.specific_source[:commit].should == '0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc' @installer.specific_source[:commit].should == FIXTURE_HEAD
pod_folder = config.sandbox.pod_dir('BananaLib') pod_folder = config.sandbox.pod_dir('BananaLib')
pod_folder.should.exist pod_folder.should.exist
end end
...@@ -45,7 +47,7 @@ module Pod ...@@ -45,7 +47,7 @@ module Pod
sources = @installer.sandbox.checkout_sources sources = @installer.sandbox.checkout_sources
sources.should == { 'BananaLib' => { sources.should == { 'BananaLib' => {
:git => SpecHelper.fixture('banana-lib'), :git => SpecHelper.fixture('banana-lib'),
:commit => '0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc' }, :commit => FIXTURE_HEAD },
} }
end end
......
...@@ -100,6 +100,7 @@ module Pod ...@@ -100,6 +100,7 @@ module Pod
it 'returns the resources' do it 'returns the resources' do
@accessor.resources.sort.should == [ @accessor.resources.sort.should == [
@root + 'Resources/Images.xcassets',
@root + 'Resources/logo-sidebar.png', @root + 'Resources/logo-sidebar.png',
@root + 'Resources/sub_dir', @root + 'Resources/sub_dir',
] ]
...@@ -138,6 +139,7 @@ module Pod ...@@ -138,6 +139,7 @@ module Pod
@spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*') @spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*')
resource_paths = [ resource_paths = [
@root + 'Resources/logo-sidebar.png', @root + 'Resources/logo-sidebar.png',
@root + 'Resources/Images.xcassets',
@root + 'Resources/sub_dir', @root + 'Resources/sub_dir',
] ]
@accessor.resource_bundles.should == { 'BananaLib' => resource_paths } @accessor.resource_bundles.should == { 'BananaLib' => resource_paths }
...@@ -147,6 +149,7 @@ module Pod ...@@ -147,6 +149,7 @@ module Pod
@spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*') @spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*')
resource_paths = [ resource_paths = [
@root + 'Resources/logo-sidebar.png', @root + 'Resources/logo-sidebar.png',
@root + 'Resources/Images.xcassets',
@root + 'Resources/sub_dir', @root + 'Resources/sub_dir',
] ]
@accessor.resource_bundle_files.should == resource_paths @accessor.resource_bundle_files.should == resource_paths
......
...@@ -13,6 +13,7 @@ module Pod ...@@ -13,6 +13,7 @@ module Pod
f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store') f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store')
end end
expected = %w( expected = %w(
Banana.modulemap
BananaLib.podspec BananaLib.podspec
Bananalib.framework/Versions/A/Headers/Bananalib.h Bananalib.framework/Versions/A/Headers/Bananalib.h
Classes/Banana.h Classes/Banana.h
...@@ -21,6 +22,8 @@ module Pod ...@@ -21,6 +22,8 @@ module Pod
Classes/BananaPrivate.h Classes/BananaPrivate.h
Classes/BananaTrace.d Classes/BananaTrace.d
README README
Resources/Images.xcassets/Logo.imageset/Contents.json
Resources/Images.xcassets/Logo.imageset/logo.png
Resources/logo-sidebar.png Resources/logo-sidebar.png
Resources/sub_dir/logo-sidebar.png Resources/sub_dir/logo-sidebar.png
libBananalib.a libBananalib.a
...@@ -45,6 +48,8 @@ module Pod ...@@ -45,6 +48,8 @@ module Pod
Bananalib.framework/Versions/Current Bananalib.framework/Versions/Current
Classes Classes
Resources Resources
Resources/Images.xcassets
Resources/Images.xcassets/Logo.imageset
Resources/sub_dir Resources/sub_dir
sub-dir sub-dir
sub-dir/sub-dir-2 sub-dir/sub-dir-2
...@@ -127,6 +132,7 @@ module Pod ...@@ -127,6 +132,7 @@ module Pod
it 'can optionally include the directories in the results' do it 'can optionally include the directories in the results' do
paths = @path_list.relative_glob('Resources/*', :include_dirs => true).map(&:to_s) paths = @path_list.relative_glob('Resources/*', :include_dirs => true).map(&:to_s)
paths.sort.should == %w( paths.sort.should == %w(
Resources/Images.xcassets
Resources/logo-sidebar.png Resources/logo-sidebar.png
Resources/sub_dir Resources/sub_dir
) )
......
...@@ -32,19 +32,28 @@ module Pod ...@@ -32,19 +32,28 @@ module Pod
it 'returns the used files' do it 'returns the used files' do
paths = @cleaner.send(:used_files) paths = @cleaner.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{@root}/", '') } relative_paths = paths.map { |p| p.gsub("#{@root}/", '') }
relative_paths.sort.should == [ relative_paths.sort.should == [
'Banana.modulemap',
'Bananalib.framework',
'Classes/Banana.h', 'Classes/Banana.h',
'Classes/Banana.m', 'Classes/Banana.m',
'Classes/BananaLib.pch', 'Classes/BananaLib.pch',
'Classes/BananaPrivate.h', 'Classes/BananaPrivate.h',
'Classes/BananaTrace.d',
'LICENSE', 'LICENSE',
'README', 'README',
'Resources/Images.xcassets',
'Resources/logo-sidebar.png', 'Resources/logo-sidebar.png',
'Resources/sub_dir',
'libBananalib.a',
'preserve_me.txt',
] ]
end end
it 'handles Pods with multiple file accessors' do it 'handles Pods with multiple file accessors' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
spec.source = { :git => SpecHelper.fixture('banana-lib') }
spec.source_files = [] spec.source_files = []
spec.ios.source_files = 'Classes/*.h' spec.ios.source_files = 'Classes/*.h'
spec.osx.source_files = 'Classes/*.m' spec.osx.source_files = 'Classes/*.m'
...@@ -55,25 +64,32 @@ module Pod ...@@ -55,25 +64,32 @@ module Pod
paths = @cleaner.send(:used_files) paths = @cleaner.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{@root}/", '') } relative_paths = paths.map { |p| p.gsub("#{@root}/", '') }
relative_paths.sort.should == [ relative_paths.sort.should == [
'Banana.modulemap',
'Bananalib.framework',
'Classes/Banana.h', 'Classes/Banana.h',
'Classes/Banana.m', 'Classes/Banana.m',
'Classes/BananaLib.pch', 'Classes/BananaLib.pch',
'Classes/BananaPrivate.h', 'Classes/BananaPrivate.h',
'LICENSE', 'LICENSE',
'README', 'README',
'Resources/Images.xcassets',
'Resources/logo-sidebar.png', 'Resources/logo-sidebar.png',
'Resources/sub_dir',
'libBananalib.a',
'preserve_me.txt',
] ]
end end
it 'compacts the used files as nil would be converted to the empty string' do it 'compacts the used files as nil would be converted to the empty string' do
Sandbox::FileAccessor.any_instance.stubs(:source_files) Sandbox::FileAccessor.any_instance.stubs(:license)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries) Sandbox::FileAccessor.any_instance.stubs(:module_map)
Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil)
Sandbox::FileAccessor.any_instance.stubs(:preserve_paths)
Sandbox::FileAccessor.any_instance.stubs(:prefix_header) Sandbox::FileAccessor.any_instance.stubs(:prefix_header)
Sandbox::FileAccessor.any_instance.stubs(:preserve_paths)
Sandbox::FileAccessor.any_instance.stubs(:readme) Sandbox::FileAccessor.any_instance.stubs(:readme)
Sandbox::FileAccessor.any_instance.stubs(:license) Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil)
Sandbox::FileAccessor.any_instance.stubs(:source_files)
Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks) Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries)
paths = @cleaner.send(:used_files) paths = @cleaner.send(:used_files)
paths.should == [] paths.should == []
end 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