Commit 9c049430 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #2831 from DanielTomlinson/2820

Use --allow-warnings rather than --error-only for pod spec validation
parents a3738991 0c8a8512
...@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Olivier Halligon](https://github.com/AliSoftware) [Olivier Halligon](https://github.com/AliSoftware)
[Core#188](https://github.com/CocoaPods/Core/issues/188) [Core#188](https://github.com/CocoaPods/Core/issues/188)
* Use `--allow-warnings` rather than `--error-only` for pod spec validation
[Daniel Tomlinson](https://github.com/DanielTomlinson)
[#2820](https://github.com/CocoaPods/CocoaPods/issues/2820)
## 0.35.0.rc2 ## 0.35.0.rc2
##### Enhancements ##### Enhancements
......
...@@ -109,23 +109,23 @@ module Pod ...@@ -109,23 +109,23 @@ module Pod
def self.options def self.options
[['--quick', 'Lint skips checks that would require to download and build the spec'], [['--quick', 'Lint skips checks that would require to download and build the spec'],
['--only-errors', 'Lint validates even if warnings are present'], ['--allow-warnings', 'Lint validates even if warnings are present'],
['--subspec=NAME', 'Lint validates only the given subspec'], ['--subspec=NAME', 'Lint validates only the given subspec'],
['--no-subspecs', 'Lint skips validation of subspecs'], ['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection'], ['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \ ['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\ '(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super) 'Multiple sources must be comma-delimited.']].concat(super)
end end
def initialize(argv) def initialize(argv)
@quick = argv.flag?('quick') @quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors') @allow_warnings = argv.flag?('allow-warnings')
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true) @subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec') @only_subspec = argv.option('subspec')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',') @source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments! @podspecs_paths = argv.arguments!
super super
end end
...@@ -137,13 +137,13 @@ module Pod ...@@ -137,13 +137,13 @@ module Pod
UI.puts UI.puts
podspecs_to_lint.each do |podspec| podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec, @source_urls) validator = Validator.new(podspec, @source_urls)
validator.local = true validator.local = true
validator.quick = @quick validator.quick = @quick
validator.no_clean = !@clean validator.no_clean = !@clean
validator.only_errors = @only_errors validator.allow_warnings = @allow_warnings
validator.no_subspecs = !@subspecs || @only_subspec validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec validator.only_subspec = @only_subspec
validator.validate validator.validate
unless @clean unless @clean
......
...@@ -83,7 +83,7 @@ module Pod ...@@ -83,7 +83,7 @@ module Pod
UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
podspec_files.each do |podspec| podspec_files.each do |podspec|
validator = Validator.new(podspec, SourcesManager.all.map(&:url)) validator = Validator.new(podspec, SourcesManager.all.map(&:url))
validator.only_errors = @allow_warnings validator.allow_warnings = @allow_warnings
begin begin
validator.validate validator.validate
rescue rescue
......
...@@ -63,23 +63,23 @@ module Pod ...@@ -63,23 +63,23 @@ module Pod
] ]
def self.options def self.options
[['--quick', 'Lint skips checks that would require to download and build the spec'], [['--quick', 'Lint skips checks that would require to download and build the spec'],
['--only-errors', 'Lint validates even if warnings are present'], ['--allow-warnings', 'Lint validates even if warnings are present'],
['--subspec=NAME', 'Lint validates only the given subspec'], ['--subspec=NAME', 'Lint validates only the given subspec'],
['--no-subspecs', 'Lint skips validation of subspecs'], ['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection'], ['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \ ['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\ '(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super) 'Multiple sources must be comma-delimited.']].concat(super)
end end
def initialize(argv) def initialize(argv)
@quick = argv.flag?('quick') @quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors') @allow_warnings = argv.flag?('allow-warnings')
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true) @subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec') @only_subspec = argv.option('subspec')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',') @source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments! @podspecs_paths = argv.arguments!
super super
end end
...@@ -88,12 +88,12 @@ module Pod ...@@ -88,12 +88,12 @@ module Pod
UI.puts UI.puts
invalid_count = 0 invalid_count = 0
podspecs_to_lint.each do |podspec| podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec, @source_urls) validator = Validator.new(podspec, @source_urls)
validator.quick = @quick validator.quick = @quick
validator.no_clean = !@clean validator.no_clean = !@clean
validator.only_errors = @only_errors validator.allow_warnings = @allow_warnings
validator.no_subspecs = !@subspecs || @only_subspec validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec validator.only_subspec = @only_subspec
validator.validate validator.validate
invalid_count += 1 unless validator.validated? invalid_count += 1 unless validator.validated?
......
...@@ -131,10 +131,9 @@ module Pod ...@@ -131,10 +131,9 @@ module Pod
attr_accessor :local attr_accessor :local
alias_method :local?, :local alias_method :local?, :local
# @return [Bool] Whether the validator should fail only on errors or also # @return [Bool] Whether the validator should fail on warnings, or only on errors.
# on warnings.
# #
attr_accessor :only_errors attr_accessor :allow_warnings
# @return [String] name of the subspec to check, if nil all subspecs are checked. # @return [String] name of the subspec to check, if nil all subspecs are checked.
# #
...@@ -155,7 +154,7 @@ module Pod ...@@ -155,7 +154,7 @@ module Pod
# @return [Boolean] # @return [Boolean]
# #
def validated? def validated?
result_type != :error && (result_type != :warning || only_errors) result_type != :error && (result_type != :warning || allow_warnings)
end end
# @return [Symbol] # @return [Symbol]
......
Subproject commit 365a0c8d93de662c019d6dbf3131f65842952357 Subproject commit d1cd4ef3462b562a2c0af97ec0c232f2e4b4823a
...@@ -174,7 +174,7 @@ module Pod ...@@ -174,7 +174,7 @@ module Pod
it 'lints the current working directory' do it 'lints the current working directory' do
Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do
cmd = command('spec', 'lint', '--quick', '--only-errors') cmd = command('spec', 'lint', '--quick', '--allow-warnings')
cmd.run cmd.run
UI.output.should.include 'passed validation' UI.output.should.include 'passed validation'
end end
...@@ -183,7 +183,7 @@ module Pod ...@@ -183,7 +183,7 @@ module Pod
# @todo VCR is required in CocoaPods only for this test. # @todo VCR is required in CocoaPods only for this test.
xit 'lints a remote podspec' do xit 'lints a remote podspec' do
Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do Dir.chdir(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/') do
cmd = command('spec', 'lint', '--quick', '--only-errors', '--silent', 'https://github.com/CocoaPods/Specs/raw/master/A2DynamicDelegate/2.0.1/A2DynamicDelegate.podspec') cmd = command('spec', 'lint', '--quick', '--allow-warnings', '--silent', 'https://github.com/CocoaPods/Specs/raw/master/A2DynamicDelegate/2.0.1/A2DynamicDelegate.podspec')
# VCR.use_cassette('linter', :record => :new_episodes) { } # VCR.use_cassette('linter', :record => :new_episodes) { }
lambda { cmd.run }.should.not.raise lambda { cmd.run }.should.not.raise
end end
...@@ -203,8 +203,8 @@ module Pod ...@@ -203,8 +203,8 @@ module Pod
UI.output.should.include 'Missing license type' UI.output.should.include 'Missing license type'
end end
it 'respects the -only--errors option' do it 'respects the --allow-warnings option' do
cmd = command('spec', 'lint', '--quick', '--only-errors', @spec_path) cmd = command('spec', 'lint', '--quick', '--allow-warnings', @spec_path)
lambda { cmd.run }.should.not.raise lambda { cmd.run }.should.not.raise
UI.output.should.include 'Missing license type' UI.output.should.include 'Missing license type'
end end
......
...@@ -72,12 +72,12 @@ module Pod ...@@ -72,12 +72,12 @@ module Pod
sut.validate sut.validate
end end
it 'respects the only errors option' do it 'respects the allow warnings option' do
podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",') podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",')
file = write_podspec(podspec) file = write_podspec(podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url)) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true sut.quick = true
sut.only_errors = true sut.allow_warnings = true
sut.validate sut.validate
sut.results.map(&:to_s).first.should.match /summary.*meaningful/ sut.results.map(&:to_s).first.should.match /summary.*meaningful/
sut.validated?.should.be.true sut.validated?.should.be.true
......
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