Commit 3760780d authored by Dov Frankel's avatar Dov Frankel

Updated validator's xcodebuild command to stream output as it runs, instead of…

Updated validator's xcodebuild command to stream output as it runs, instead of holding it until the end, when given the --verbose flag (issue #7040)
parent 1680ff7b
......@@ -61,6 +61,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
* Document format of POD_NAMES in pod update
[mrh-is](https://github.com/mrh-is)
* Update validator to stream output as xcodebuild runs
[abbeycode](https://github.com/abbeycode)
[#7040](https://github.com/CocoaPods/CocoaPods/issues/7040)
##### Bug Fixes
* Prevent `xcassets` compilation from stomping over the apps `xcassets`
......
......@@ -576,7 +576,6 @@ module Pod
UI.warn "Skipping compilation with `xcodebuild` because target contains no sources.\n".yellow
else
output = xcodebuild('build', scheme, 'Release')
UI.puts output
parsed_output = parse_xcodebuild_output(output)
translate_output_to_linter_messages(parsed_output)
end
......@@ -600,7 +599,6 @@ module Pod
consumer.spec.test_specs.each do |test_spec|
scheme = pod_target.native_target_for_spec(test_spec)
output = xcodebuild('test', scheme, 'Debug')
UI.puts output
parsed_output = parse_xcodebuild_output(output)
translate_output_to_linter_messages(parsed_output)
end
......@@ -873,25 +871,22 @@ module Pod
command += Fourflusher::SimControl.new.destination(:oldest, 'tvOS', deployment_target)
end
output, status = _xcodebuild(command)
unless status.success?
begin
_xcodebuild(command, true)
rescue => e
message = 'Returned an unsuccessful exit code.'
message += ' You can use `--verbose` for more information.' unless config.verbose?
error('xcodebuild', message)
e.message
end
output
end
# Executes the given command in the current working directory.
#
# @return [(String, Status)] The output of the given command and its
# resulting status.
# @return [String] The output of the given command
#
def _xcodebuild(command)
UI.puts 'xcodebuild ' << command.join(' ') if config.verbose
Executable.capture_command('xcodebuild', command, :capture => :merge)
def _xcodebuild(command, raise_on_failure = false)
Executable.execute_command('xcodebuild', command, raise_on_failure)
end
#-------------------------------------------------------------------------#
......
......@@ -491,9 +491,7 @@ module Pod
git = Executable.which(:git)
Executable.stubs(:which).with('git').returns(git)
Executable.stubs(:which).with(:xcrun)
status = mock
status.stubs(:success?).returns(false)
validator.stubs(:_xcodebuild).returns(['Output', status])
validator.stubs(:_xcodebuild).raises(Informative)
validator.validate
first = validator.results.map(&:to_s).first
first.should.include '[xcodebuild] Returned an unsuccessful exit code'
......@@ -504,6 +502,7 @@ module Pod
require 'fourflusher'
Fourflusher::SimControl.any_instance.stubs(:destination).returns(['-destination', 'id=XXX'])
Validator.any_instance.unstub(:xcodebuild)
PodTarget.any_instance.stubs(:should_build?).returns(true)
validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url))
validator.stubs(:check_file_patterns)
validator.stubs(:validate_url)
......@@ -512,16 +511,17 @@ module Pod
Executable.stubs(:which).with('git').returns(git)
Executable.stubs(:capture_command).with('git', ['config', '--get', 'remote.origin.url'], :capture => :out).returns(['https://github.com/CocoaPods/Specs.git'])
Executable.stubs(:which).with(:xcrun)
Executable.expects(:execute_command).with { |executable, command, _| executable == 'git' && command.first == 'clone' }.once
# Command should include the pod target 'JSONKit' instead of the 'App' target.
command = ['clean', 'build', '-workspace', File.join(validator.validation_dir, 'App.xcworkspace'), '-scheme', 'JSONKit', '-configuration', 'Release']
args = %w(CODE_SIGN_IDENTITY=)
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
args = %w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator) + Fourflusher::SimControl.new.destination('Apple TV 1080p')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
args = %w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator) + Fourflusher::SimControl.new.destination('iPhone 4s')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
args = %w(CODE_SIGN_IDENTITY=- -sdk watchsimulator) + Fourflusher::SimControl.new.destination('Apple Watch - 38mm')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
validator.validate
end
......@@ -536,15 +536,16 @@ module Pod
Executable.stubs(:which).with('git').returns(git)
Executable.stubs(:capture_command).with('git', ['config', '--get', 'remote.origin.url'], :capture => :out).returns(['https://github.com/CocoaPods/Specs.git'])
Executable.stubs(:which).with(:xcrun)
Executable.expects(:execute_command).with { |executable, command, _| executable == 'git' && command.first == 'clone' }.once
command = ['clean', 'build', '-workspace', File.join(validator.validation_dir, 'App.xcworkspace'), '-scheme', 'App', '-configuration', 'Release']
args = %w(CODE_SIGN_IDENTITY=)
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
args = %w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator) + Fourflusher::SimControl.new.destination('Apple TV 1080p')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
args = %w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator) + Fourflusher::SimControl.new.destination('iPhone 4s')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
args = %w(CODE_SIGN_IDENTITY=- -sdk watchsimulator) + Fourflusher::SimControl.new.destination('Apple Watch - 38mm')
Executable.expects(:capture_command).with('xcodebuild', command + args, :capture => :merge).once.returns(['', stub(:success? => true)])
Executable.expects(:execute_command).with('xcodebuild', command + args, true).once.returns('')
validator.validate
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