Commit 68b677eb authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #2566 from CocoaPods/validator-sources

[Validator] Allow the validator to take specific sources
parents 89474b59 c1704945
......@@ -7,14 +7,21 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
##### Bug Fixes
* Improved sanitizing of configuration names to avoid generating invalid
preprocessor definitions.
preprocessor definitions.
[Boris Bügling](https://github.com/neonichu)
[#2542](https://github.com/CocoaPods/CocoaPods/issues/2542)
* More robust generation of source names from URLs.
* More robust generation of source names from URLs.
[Samuel Giddins](https://github.com/segiddins)
[#2534](https://github.com/CocoaPods/CocoaPods/issues/2534)
* Allow the `Validator` to only use specific sources.
Allows customizable source for `pod spec lint` and `pod lib lint`,
with both defaulting to `master`.
[Samuel Giddins](https://github.com/segiddins)
[#2543](https://github.com/CocoaPods/CocoaPods/issues/2543)
[cocoapods-trunk#28](https://github.com/CocoaPods/cocoapods-trunk/issues/28)
## 0.34.1
......
......@@ -112,7 +112,9 @@ module Pod
['--only-errors', 'Lint validates even if warnings are present'],
['--subspec=NAME', 'Lint validates only the given subspec'],
['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection']].concat(super)
['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--sources=https://github.com/artsy/Specs', 'The sources to pull dependant pods from ' \
'(defaults to https://github.com/CocoaPods/Specs.git)']].concat(super)
end
def initialize(argv)
......@@ -121,6 +123,7 @@ module Pod
@clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments!
super
end
......@@ -133,7 +136,7 @@ module Pod
UI.puts
podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec)
validator = Validator.new(podspec, @source_urls)
validator.local = true
validator.quick = @quick
validator.no_clean = !@clean
......
......@@ -82,7 +82,7 @@ module Pod
def validate_podspec_files
UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
podspec_files.each do |podspec|
validator = Validator.new(podspec)
validator = Validator.new(podspec, SourcesManager.all.map(&:url))
validator.only_errors = @allow_warnings
begin
validator.validate
......
......@@ -67,7 +67,9 @@ module Pod
['--only-errors', 'Lint validates even if warnings are present'],
['--subspec=NAME', 'Lint validates only the given subspec'],
['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection']].concat(super)
['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--sources=https://github.com/artsy/Specs', 'The sources to pull dependant pods from ' \
'(defaults to https://github.com/CocoaPods/Specs.git)']].concat(super)
end
def initialize(argv)
......@@ -76,6 +78,7 @@ module Pod
@clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments!
super
end
......@@ -84,7 +87,7 @@ module Pod
UI.puts
invalid_count = 0
podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec)
validator = Validator.new(podspec, @source_urls)
validator.quick = @quick
validator.no_clean = !@clean
validator.only_errors = @only_errors
......
......@@ -19,7 +19,11 @@ module Pod
# @param [Specification, Pathname, String] spec_or_path
# the Specification or the path of the `podspec` file to lint.
#
def initialize(spec_or_path)
# @param [Array<String>] source_urls
# the Source URLs to use in creating a {Podfile}.
#
def initialize(spec_or_path, source_urls)
@source_urls = source_urls
@linter = Specification::Linter.new(spec_or_path)
end
......@@ -412,6 +416,13 @@ module Pod
# !@group Helpers
# @return [Array<Source>] an array of sources used to create the
# {Podfile} used in the linting process
#
def sources
@sources ||= @source_urls.map { |url| SourcesManager.find_or_create_source_with_url(url) }
end
# @return [Podfile] a podfile that requires the specification on the
# current platform.
#
......@@ -423,6 +434,7 @@ module Pod
podspec = file.realpath
local = local?
podfile = Pod::Podfile.new do
sources.each { |s| source(s.url) }
platform(platform_name, deployment_target)
if local
pod name, :path => podspec.dirname.to_s
......
......@@ -47,7 +47,7 @@ module Pod
describe 'Quick mode' do
it 'validates a correct podspec' do
sut = Validator.new(podspec_path)
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.quick = true
sut.validate
sut.results.should == []
......@@ -57,7 +57,7 @@ module Pod
it 'lints the podspec during validation' do
podspec = stub_podspec(/.*name.*/, '"name": "TEST",')
file = write_podspec(podspec)
sut = Validator.new(file)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.validate
sut.results.map(&:to_s).first.should.match /should match the name/
......@@ -66,7 +66,7 @@ module Pod
it 'respects quick mode' do
file = write_podspec(stub_podspec)
sut = Validator.new(file)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.expects(:perform_extensive_analysis).never
sut.validate
......@@ -75,7 +75,7 @@ module Pod
it 'respects the only errors option' do
podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",')
file = write_podspec(podspec)
sut = Validator.new(file)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.only_errors = true
sut.validate
......@@ -85,7 +85,7 @@ module Pod
it 'handles symlinks' do
file = write_podspec(stub_podspec)
validator = Validator.new(file)
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.quick = true
validator.stubs(:validate_url)
validator.validate
......@@ -99,7 +99,7 @@ module Pod
describe 'URL validation' do
before do
@sut = Validator.new(podspec_path)
@sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@sut.stubs(:install_pod)
@sut.stubs(:build_pod)
@sut.stubs(:check_file_patterns)
......@@ -257,7 +257,7 @@ module Pod
it 'respects the no clean option' do
file = write_podspec(stub_podspec)
sut = Validator.new(file)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.no_clean = true
sut.validate
......@@ -266,7 +266,7 @@ module Pod
it 'builds the pod per platform' do
file = write_podspec(stub_podspec)
sut = Validator.new(file)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.expects(:install_pod).twice
sut.expects(:build_pod).twice
......@@ -275,7 +275,7 @@ module Pod
end
it 'uses the deployment target of the specification' do
sut = Validator.new(podspec_path)
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.stubs(:validate_screenshots)
podfile = sut.send(:podfile_from_spec, :ios, '5.0')
......@@ -284,7 +284,7 @@ module Pod
end
it 'respects the local option' do
sut = Validator.new(podspec_path)
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
podfile = sut.send(:podfile_from_spec, :ios, '5.0')
deployment_target = podfile.target_definitions['Pods'].platform.deployment_target
......@@ -292,7 +292,7 @@ module Pod
end
it 'uses xcodebuild to generate notes and warnings' do
sut = Validator.new(podspec_path)
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:check_file_patterns)
sut.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated")
sut.stubs(:validate_url)
......@@ -313,7 +313,7 @@ module Pod
it 'checks for file patterns' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "wrong_paht.*",'))
sut = Validator.new(file)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:build_pod)
sut.stubs(:validate_url)
sut.validate
......@@ -328,7 +328,7 @@ module Pod
file = write_podspec(podspec, 'ZKit.podspec.json')
spec = Specification.from_file(file)
sut = Validator.new(spec)
sut = Validator.new(spec, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.stubs(:build_pod)
sut.validate
......
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