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
unit_specs_command = "bundle exec bacon #{specs('unit/**/*')}"
desc 'Run the unit specs'
task :unit => :unpack_fixture_tarballs do
task :unit => 'fixture_tarballs:unpack' do
sh unit_specs_command
end
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"
end
#--------------------------------------#
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 => '**/*')
sh "bundle exec bacon #{specs("functional/#{args[:spec]}")}"
end
......@@ -126,7 +126,7 @@ begin
# The specs helper interfere with the integration 2 specs and thus they need
# to be run separately.
#
task :all => :unpack_fixture_tarballs do
task :all => 'fixture_tarballs:unpack' do
ENV['GENERATE_COVERAGE'] = 'true'
puts "\033[0;32mUsing #{`ruby --version`}\033[0m"
......@@ -143,22 +143,42 @@ begin
Rake::Task['rubocop'].invoke
end
desc 'Rebuild all the fixture tarballs'
task :rebuild_fixture_tarballs 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]}"
namespace :fixture_tarballs do
task :default => :unpack
desc 'Check fixture tarballs for pending changes'
task :check_for_pending_changes do
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
desc 'Unpacks all the fixture tarballs'
task :unpack_fixture_tarballs do
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}"
desc 'Unpacks all the fixture tarballs'
task :unpack, :force do |_t, args|
begin
Rake::Task['spec:fixture_tarballs:check_for_pending_changes'].invoke
rescue SystemExit
exit 1 unless args[:force]
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
......@@ -201,7 +221,7 @@ begin
puts 'Integration fixtures updated, commit and push in the `spec/cocoapods-integration-specs` submodule'
end
task :clean_env => [:clean_vcr, :unpack_fixture_tarballs, 'ext:cleanbuild']
task :clean_env => [:clean_vcr, 'fixture_tarballs:unpack', 'ext:cleanbuild']
end
# Examples
......
......@@ -130,8 +130,7 @@ module Pod
private_header_files
end
# @return [Hash{ Symbol => Array<Pathname> }] the resources of the
# specification grouped by destination.
# @return [Array<Pathname>] the resources of the specification.
#
def resources
paths_for_attribute(:resources, true)
......@@ -268,15 +267,22 @@ module Pod
# Matches the given patterns to the file present in the root of the path
# list.
#
# @param [Array<String>] patterns
# @param [Array<String>] patterns
# 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.
#
# @param [Array<String>] exclude_patterns
# @option options [Array<String>] :exclude_patterns
# 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.
#
# @return [Array<Pathname>] A list of the paths.
......
......@@ -75,6 +75,7 @@ module Pod
file_accessors.map(&:readme),
file_accessors.map(&:resources),
file_accessors.map(&:source_files),
file_accessors.map(&:module_map),
]
files.flatten.compact.map(&:to_s).uniq
......
......@@ -2,6 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Installer::PodSourceInstaller do
FIXTURE_HEAD = Dir.chdir(SpecHelper.fixture('banana-lib')) { `git rev-parse HEAD`.chomp }
before do
@spec = fixture_spec('banana-lib/BananaLib.podspec')
@spec.source = { :git => SpecHelper.fixture('banana-lib') }
......@@ -25,7 +27,7 @@ module Pod
config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install!
@installer.specific_source[:commit].should == '0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc'
@installer.specific_source[:commit].should == FIXTURE_HEAD
pod_folder = config.sandbox.pod_dir('BananaLib')
pod_folder.should.exist
end
......@@ -45,7 +47,7 @@ module Pod
sources = @installer.sandbox.checkout_sources
sources.should == { 'BananaLib' => {
:git => SpecHelper.fixture('banana-lib'),
:commit => '0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc' },
:commit => FIXTURE_HEAD },
}
end
......
......@@ -100,6 +100,7 @@ module Pod
it 'returns the resources' do
@accessor.resources.sort.should == [
@root + 'Resources/Images.xcassets',
@root + 'Resources/logo-sidebar.png',
@root + 'Resources/sub_dir',
]
......@@ -138,6 +139,7 @@ module Pod
@spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*')
resource_paths = [
@root + 'Resources/logo-sidebar.png',
@root + 'Resources/Images.xcassets',
@root + 'Resources/sub_dir',
]
@accessor.resource_bundles.should == { 'BananaLib' => resource_paths }
......@@ -147,6 +149,7 @@ module Pod
@spec_consumer.stubs(:resource_bundles).returns('BananaLib' => 'Resources/*')
resource_paths = [
@root + 'Resources/logo-sidebar.png',
@root + 'Resources/Images.xcassets',
@root + 'Resources/sub_dir',
]
@accessor.resource_bundle_files.should == resource_paths
......
......@@ -13,6 +13,7 @@ module Pod
f.include?('libPusher') || f.include?('.git') || f.include?('DS_Store')
end
expected = %w(
Banana.modulemap
BananaLib.podspec
Bananalib.framework/Versions/A/Headers/Bananalib.h
Classes/Banana.h
......@@ -21,6 +22,8 @@ module Pod
Classes/BananaPrivate.h
Classes/BananaTrace.d
README
Resources/Images.xcassets/Logo.imageset/Contents.json
Resources/Images.xcassets/Logo.imageset/logo.png
Resources/logo-sidebar.png
Resources/sub_dir/logo-sidebar.png
libBananalib.a
......@@ -45,6 +48,8 @@ module Pod
Bananalib.framework/Versions/Current
Classes
Resources
Resources/Images.xcassets
Resources/Images.xcassets/Logo.imageset
Resources/sub_dir
sub-dir
sub-dir/sub-dir-2
......@@ -127,6 +132,7 @@ module Pod
it 'can optionally include the directories in the results' do
paths = @path_list.relative_glob('Resources/*', :include_dirs => true).map(&:to_s)
paths.sort.should == %w(
Resources/Images.xcassets
Resources/logo-sidebar.png
Resources/sub_dir
)
......
......@@ -32,19 +32,28 @@ module Pod
it 'returns the used files' do
paths = @cleaner.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{@root}/", '') }
relative_paths.sort.should == [
'Banana.modulemap',
'Bananalib.framework',
'Classes/Banana.h',
'Classes/Banana.m',
'Classes/BananaLib.pch',
'Classes/BananaPrivate.h',
'Classes/BananaTrace.d',
'LICENSE',
'README',
'Resources/Images.xcassets',
'Resources/logo-sidebar.png',
'Resources/sub_dir',
'libBananalib.a',
'preserve_me.txt',
]
end
it 'handles Pods with multiple file accessors' do
spec = fixture_spec('banana-lib/BananaLib.podspec')
spec.source = { :git => SpecHelper.fixture('banana-lib') }
spec.source_files = []
spec.ios.source_files = 'Classes/*.h'
spec.osx.source_files = 'Classes/*.m'
......@@ -55,25 +64,32 @@ module Pod
paths = @cleaner.send(:used_files)
relative_paths = paths.map { |p| p.gsub("#{@root}/", '') }
relative_paths.sort.should == [
'Banana.modulemap',
'Bananalib.framework',
'Classes/Banana.h',
'Classes/Banana.m',
'Classes/BananaLib.pch',
'Classes/BananaPrivate.h',
'LICENSE',
'README',
'Resources/Images.xcassets',
'Resources/logo-sidebar.png',
'Resources/sub_dir',
'libBananalib.a',
'preserve_me.txt',
]
end
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(:vendored_libraries)
Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil)
Sandbox::FileAccessor.any_instance.stubs(:preserve_paths)
Sandbox::FileAccessor.any_instance.stubs(:license)
Sandbox::FileAccessor.any_instance.stubs(:module_map)
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(: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_libraries)
paths = @cleaner.send(:used_files)
paths.should == []
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