Commit eba4bf58 authored by Daniel Tomlinson's avatar Daniel Tomlinson

Use --allow-warnings rather than --error-only for pod spec validation

parent a3738991
......@@ -109,23 +109,23 @@ module Pod
def self.options
[['--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'],
['--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 ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super)
end
def initialize(argv)
@quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors')
@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!
@quick = argv.flag?('quick')
@allow_warnings = argv.flag?('allow-warnings')
@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
......@@ -137,13 +137,13 @@ module Pod
UI.puts
podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec, @source_urls)
validator.local = true
validator.quick = @quick
validator.no_clean = !@clean
validator.only_errors = @only_errors
validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec
validator = Validator.new(podspec, @source_urls)
validator.local = true
validator.quick = @quick
validator.no_clean = !@clean
validator.allow_warnings = @allow_warnings
validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec
validator.validate
unless @clean
......
......@@ -83,7 +83,7 @@ module Pod
UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
podspec_files.each do |podspec|
validator = Validator.new(podspec, SourcesManager.all.map(&:url))
validator.only_errors = @allow_warnings
validator.allow_warnings = @allow_warnings
begin
validator.validate
rescue
......
......@@ -63,23 +63,23 @@ module Pod
]
def self.options
[['--quick', 'Lint skips checks that would require to download and build the spec'],
['--only-errors', 'Lint validates even if warnings are present'],
[['--quick', 'Lint skips checks that would require to download and build the spec'],
['--allow-warnings', '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'],
['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super)
end
def initialize(argv)
@quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors')
@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(',')
@quick = argv.flag?('quick')
@allow_warnings = argv.flag?('allow-warnings')
@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
......@@ -88,12 +88,12 @@ module Pod
UI.puts
invalid_count = 0
podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec, @source_urls)
validator.quick = @quick
validator.no_clean = !@clean
validator.only_errors = @only_errors
validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec
validator = Validator.new(podspec, @source_urls)
validator.quick = @quick
validator.no_clean = !@clean
validator.allow_warnings = @allow_warnings
validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec
validator.validate
invalid_count += 1 unless validator.validated?
......
......@@ -131,10 +131,9 @@ module Pod
attr_accessor :local
alias_method :local?, :local
# @return [Bool] Whether the validator should fail only on errors or also
# on warnings.
# @return [Bool] Whether the validator should fail on warnings, or only on errors.
#
attr_accessor :only_errors
attr_accessor :allow_warnings
# @return [String] name of the subspec to check, if nil all subspecs are checked.
#
......@@ -155,7 +154,7 @@ module Pod
# @return [Boolean]
#
def validated?
result_type != :error && (result_type != :warning || only_errors)
result_type != :error && (result_type != :warning || allow_warnings)
end
# @return [Symbol]
......
......@@ -174,7 +174,7 @@ module Pod
it 'lints the current working directory' 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
UI.output.should.include 'passed validation'
end
......@@ -183,7 +183,7 @@ module Pod
# @todo VCR is required in CocoaPods only for this test.
xit 'lints a remote podspec' 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) { }
lambda { cmd.run }.should.not.raise
end
......@@ -203,8 +203,8 @@ module Pod
UI.output.should.include 'Missing license type'
end
it 'respects the -only--errors option' do
cmd = command('spec', 'lint', '--quick', '--only-errors', @spec_path)
it 'respects the --allow-warnings option' do
cmd = command('spec', 'lint', '--quick', '--allow-warnings', @spec_path)
lambda { cmd.run }.should.not.raise
UI.output.should.include 'Missing license type'
end
......
......@@ -72,12 +72,12 @@ module Pod
sut.validate
end
it 'respects the only errors option' do
it 'respects the allow warnings option' do
podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",')
file = write_podspec(podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.only_errors = true
sut.allow_warnings = true
sut.validate
sut.results.map(&:to_s).first.should.match /summary.*meaningful/
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